Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e106e5c

Browse files
committed
Issue #19437: Fix error handling of PyCArrayType_new(), don't decreases the
reference counter of stgdict after result stole a reference to it
1 parent 2399ad5 commit e106e5c

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Modules/_ctypes/_ctypes.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,8 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
13421342
if (-1 == PyDict_Update((PyObject *)stgdict, result->tp_dict))
13431343
goto error;
13441344
Py_DECREF(result->tp_dict);
1345-
result->tp_dict = (PyObject *)stgdict;
1345+
result->tp_dict = (PyObject *)stgdict; /* steal the reference */
1346+
stgdict = NULL;
13461347

13471348
/* Special case for character arrays.
13481349
A permanent annoyance: char arrays are also strings!

0 commit comments

Comments
 (0)