Skip to content

Commit 5e33378

Browse files
ZackerySpytzserhiy-storchaka
authored andcommitted
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.
1 parent dd5417a commit 5e33378

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
@@ -1522,6 +1522,7 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
15221522
stgdict->align = itemalign;
15231523
stgdict->length = length;
15241524
stgdict->proto = type_attr;
1525+
type_attr = NULL;
15251526

15261527
stgdict->paramfunc = &PyCArrayType_paramfunc;
15271528

0 commit comments

Comments
 (0)