[Python-checkins] r68575 - python/trunk/Modules/_ctypes/cfield.c
thomas.heller
python-checkins at python.org
Tue Jan 13 18:32:28 CET 2009
Author: thomas.heller
Date: Tue Jan 13 18:32:28 2009
New Revision: 68575
Log:
Fix refcount leak in error cases. Bug found by coverity.
Modified:
python/trunk/Modules/_ctypes/cfield.c
Modified: python/trunk/Modules/_ctypes/cfield.c
==============================================================================
--- python/trunk/Modules/_ctypes/cfield.c (original)
+++ python/trunk/Modules/_ctypes/cfield.c Tue Jan 13 18:32:28 2009
@@ -1452,11 +1452,14 @@
size += 1; /* terminating NUL */
size *= sizeof(wchar_t);
buffer = (wchar_t *)PyMem_Malloc(size);
- if (!buffer)
+ if (!buffer) {
+ Py_DECREF(value);
return PyErr_NoMemory();
+ }
memset(buffer, 0, size);
keep = PyCObject_FromVoidPtr(buffer, PyMem_Free);
if (!keep) {
+ Py_DECREF(value);
PyMem_Free(buffer);
return NULL;
}
More information about the Python-checkins
mailing list