]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-36421: Fix a possible double decref in _ctypes.c's PyCArrayType_new(). (GH-12530)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 25 Mar 2019 08:34:26 +0000 (01:34 -0700)
committerGitHub <noreply@github.com>
Mon, 25 Mar 2019 08:34:26 +0000 (01:34 -0700)
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 <zspytz@gmail.com>
Misc/NEWS.d/next/Core and Builtins/2019-03-24-21-33-22.bpo-36421.gJ2Pv9.rst [new file with mode: 0644]
Modules/_ctypes/_ctypes.c

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 (file)
index 0000000..2577511
--- /dev/null
@@ -0,0 +1 @@
+Fix a possible double decref in _ctypes.c's ``PyCArrayType_new()``.
index f98eabbb370b50a1d3373c35e3e6253f82c62dc8..48ad696e10783b147d4d075b6d3e1c2621957180 100644 (file)
@@ -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;