Skip to content

Commit fa27870

Browse files
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 5e33378) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
1 parent 9dbb09f commit fa27870

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a possible double decref in _ctypes.c's ``PyCArrayType_new()``.

Modules/_ctypes/_ctypes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,7 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
14811481
stgdict->align = itemalign;
14821482
stgdict->length = length;
14831483
stgdict->proto = type_attr;
1484+
type_attr = NULL;
14841485

14851486
stgdict->paramfunc = &PyCArrayType_paramfunc;
14861487

0 commit comments

Comments
 (0)