diff options
author | Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com> | 2022-04-17 06:52:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-17 06:52:53 (GMT) |
commit | 3289209716011b21128f45de69f4a8e9d376c78e (patch) | |
tree | 68fc0d31d42150c2bf637f4547011993499074ab /Python/errors.c | |
parent | 37965d2fb434d8343d5c70fb6a462a16ae7882b8 (diff) | |
download | cpython-3289209716011b21128f45de69f4a8e9d376c78e.zip cpython-3289209716011b21128f45de69f4a8e9d376c78e.tar.gz cpython-3289209716011b21128f45de69f4a8e9d376c78e.tar.bz2 |
Fix refleaks in PyErr_SetHandledException (GH-91627)
Diffstat (limited to 'Python/errors.c')
-rw-r--r-- | Python/errors.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Python/errors.c b/Python/errors.c index ce77858..3eb8a5e 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -520,9 +520,7 @@ PyErr_GetHandledException(void) void _PyErr_SetHandledException(PyThreadState *tstate, PyObject *exc) { - PyObject *oldexc = tstate->exc_info->exc_value; - tstate->exc_info->exc_value = Py_XNewRef(exc); - Py_XDECREF(oldexc); + Py_XSETREF(tstate->exc_info->exc_value, Py_XNewRef(exc)); } void @@ -543,6 +541,7 @@ void PyErr_SetExcInfo(PyObject *type, PyObject *value, PyObject *traceback) { PyErr_SetHandledException(value); + Py_XDECREF(value); /* These args are no longer used, but we still need to steal a ref */ Py_XDECREF(type); Py_XDECREF(traceback); |