From: Victor Stinner Date: Mon, 18 Nov 2013 17:37:33 +0000 (+0100) Subject: Issue #19437: Fix error handling of PyCArrayType_new(), don't decreases the X-Git-Tag: v3.4.0b1~195 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e106e5ce4b995e9b77ecd256c8062e95f74fae04;p=thirdparty%2FPython%2Fcpython.git Issue #19437: Fix error handling of PyCArrayType_new(), don't decreases the reference counter of stgdict after result stole a reference to it --- diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index be0f33a69e9f..820a6060950a 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -1342,7 +1342,8 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) if (-1 == PyDict_Update((PyObject *)stgdict, result->tp_dict)) goto error; Py_DECREF(result->tp_dict); - result->tp_dict = (PyObject *)stgdict; + result->tp_dict = (PyObject *)stgdict; /* steal the reference */ + stgdict = NULL; /* Special case for character arrays. A permanent annoyance: char arrays are also strings!