From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 25 Mar 2019 08:34:26 +0000 (-0700) Subject: bpo-36421: Fix a possible double decref in _ctypes.c's PyCArrayType_new(). (GH-12530) X-Git-Tag: v3.7.4rc1~301 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fa27870992a7228c8bf378d53649ee22333b69db;p=thirdparty%2FPython%2Fcpython.git bpo-36421: Fix a possible double decref in _ctypes.c's PyCArrayType_new(). (GH-12530) Set type_attr to NULL after the assignment to stgdict->proto (like what is done with stgdict after the Py_SETREF() call) so that it is not decrefed twice on error. (cherry picked from commit 5e333784f007950f22de44c1ffab5b0c03d6691f) Co-authored-by: Zackery Spytz --- diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-03-24-21-33-22.bpo-36421.gJ2Pv9.rst b/Misc/NEWS.d/next/Core and Builtins/2019-03-24-21-33-22.bpo-36421.gJ2Pv9.rst new file mode 100644 index 000000000000..2577511de2e2 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2019-03-24-21-33-22.bpo-36421.gJ2Pv9.rst @@ -0,0 +1 @@ +Fix a possible double decref in _ctypes.c's ``PyCArrayType_new()``. diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index f98eabbb370b..48ad696e1078 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -1481,6 +1481,7 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) stgdict->align = itemalign; stgdict->length = length; stgdict->proto = type_attr; + type_attr = NULL; stgdict->paramfunc = &PyCArrayType_paramfunc;