diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-03-19 15:18:24 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-19 15:18:24 +0000 |
commit | ccb5af7bfee59b72313ccf1fa2c9b0dca347ac96 (patch) | |
tree | 90f5f8790cba21fef8cc51ddfdae5b18b09d6fbd /Python/pylifecycle.c | |
parent | ad77b80b0542a71eff54d1a193bd044a71e8e00b (diff) | |
download | cpython-ccb5af7bfee59b72313ccf1fa2c9b0dca347ac96.tar.gz cpython-ccb5af7bfee59b72313ccf1fa2c9b0dca347ac96.zip |
gh-102755: fix refleak (#102826)
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r-- | Python/pylifecycle.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 7bf12271db2..317d6966d03 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -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)); |