[Python-checkins] r59927 - python/trunk/Modules/_ctypes/_ctypes.c

thomas.heller python-checkins at python.org
Fri Jan 11 21:29:20 CET 2008


Author: thomas.heller
Date: Fri Jan 11 21:29:19 2008
New Revision: 59927

Modified:
   python/trunk/Modules/_ctypes/_ctypes.c
Log:
Fix a potential 'SystemError: NULL result without error'.
NULL may be a valid return value from PyLong_AsVoidPtr.

Will backport to release25-maint.

Modified: python/trunk/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/trunk/Modules/_ctypes/_ctypes.c	(original)
+++ python/trunk/Modules/_ctypes/_ctypes.c	Fri Jan 11 21:29:19 2008
@@ -2899,7 +2899,7 @@
 		|| PyLong_Check(PyTuple_GET_ITEM(args, 0)))) {
 		CDataObject *ob;
 		void *ptr = PyLong_AsVoidPtr(PyTuple_GET_ITEM(args, 0));
-		if (ptr == NULL)
+		if (ptr == NULL && PyErr_Occurred())
 			return NULL;
 		ob = (CDataObject *)GenericCData_new(type, args, kwds);
 		if (ob == NULL)


More information about the Python-checkins mailing list