From: Berker Peksag Date: Sun, 1 May 2016 06:06:36 +0000 (+0300) Subject: Issue #23960: Cleanup args and kwargs on error in PyErr_SetImportError X-Git-Tag: v3.6.0a1~91^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ec766d3c159e0526db641505dbdf0a7f4271e5e4;p=thirdparty%2FPython%2Fcpython.git Issue #23960: Cleanup args and kwargs on error in PyErr_SetImportError Patch by Ofer Schwarz. --- diff --git a/Python/errors.c b/Python/errors.c index 47d7c4b99241..e151cab17cb5 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -727,9 +727,9 @@ PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path) PyTuple_SET_ITEM(args, 0, msg); if (PyDict_SetItemString(kwargs, "name", name) < 0) - return NULL; + goto done; if (PyDict_SetItemString(kwargs, "path", path) < 0) - return NULL; + goto done; error = PyObject_Call(PyExc_ImportError, args, kwargs); if (error != NULL) { @@ -737,9 +737,9 @@ PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path) Py_DECREF(error); } +done: Py_DECREF(args); Py_DECREF(kwargs); - return NULL; }