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 5e333784f0)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
This commit is contained in:
Miss Islington (bot) 2019-03-25 01:34:26 -07:00 committed by GitHub
parent 9dbb09fc27
commit fa27870992
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View file

@ -0,0 +1 @@
Fix a possible double decref in _ctypes.c's ``PyCArrayType_new()``.

View 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;