[Python-checkins] r60002 - in python/branches/release25-maint: Misc/NEWS Modules/_ctypes/_ctypes.c

thomas.heller python-checkins at python.org
Wed Jan 16 20:24:21 CET 2008


Author: thomas.heller
Date: Wed Jan 16 20:24:20 2008
New Revision: 60002

Modified:
   python/branches/release25-maint/Misc/NEWS
   python/branches/release25-maint/Modules/_ctypes/_ctypes.c
Log:
Backport from trunk:
  Fix a potential 'SystemError: NULL result without error'.
  NULL may be a valid return value from PyLong_AsVoidPtr.
Also move an older ctypes NEWS item in the correct category.



Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Wed Jan 16 20:24:20 2008
@@ -12,8 +12,6 @@
 Core and builtins
 -----------------
 
-- Prevent a segfault when a ctypes NULL function pointer is called.
-
 - Bug #1517: Possible segfault in lookup().
 
 - Issue #1638: %zd configure test fails on Linux.
@@ -171,6 +169,10 @@
 Extension Modules
 -----------------
 
+- Fix a potential 'SystemError: NULL result without error' in _ctypes.
+
+- Prevent a segfault when a ctypes NULL function pointer is called.
+
 - Bug #1301: Bad assert in _tkinter fixed.
 
 - Patch #1114: fix curses module compilation on 64-bit AIX, & possibly

Modified: python/branches/release25-maint/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/branches/release25-maint/Modules/_ctypes/_ctypes.c	(original)
+++ python/branches/release25-maint/Modules/_ctypes/_ctypes.c	Wed Jan 16 20:24:20 2008
@@ -2896,7 +2896,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