]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-102755: fix refleak (#102826)
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>
Sun, 19 Mar 2023 15:18:24 +0000 (15:18 +0000)
committerGitHub <noreply@github.com>
Sun, 19 Mar 2023 15:18:24 +0000 (15:18 +0000)
Python/pylifecycle.c

index 7bf12271db23233c0d7638a94521414d6ff41ad3..317d6966d034fa961cbcc83649e16f3f1e16f773 100644 (file)
@@ -2547,6 +2547,7 @@ _Py_FatalError_PrintExc(PyThreadState *tstate)
     if (ferr == NULL || ferr == Py_None) {
         /* sys.stderr is not set yet or set to None,
            no need to try to display the exception */
+        Py_DECREF(exc);
         return 0;
     }
 
@@ -2555,7 +2556,7 @@ _Py_FatalError_PrintExc(PyThreadState *tstate)
     PyObject *tb = PyException_GetTraceback(exc);
     int has_tb = (tb != NULL) && (tb != Py_None);
     Py_XDECREF(tb);
-    Py_XDECREF(exc);
+    Py_DECREF(exc);
 
     /* sys.stderr may be buffered: call sys.stderr.flush() */
     PyObject *res = PyObject_CallMethodNoArgs(ferr, &_Py_ID(flush));