]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-36421: Fix a possible double decref in _ctypes.c's PyCArrayType_new(). (GH-12530)
authorZackery Spytz <zspytz@gmail.com>
Mon, 25 Mar 2019 08:07:47 +0000 (02:07 -0600)
committerSerhiy Storchaka <storchaka@gmail.com>
Mon, 25 Mar 2019 08:07:47 +0000 (10:07 +0200)
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.

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 0d95d2b6f76ecebd9f104fe595ff5cd45bfe185e..45102f3304ec6a598341821f98c138141f316dd4 100644 (file)
@@ -1522,6 +1522,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;