]> granicus.if.org Git - python/commitdiff
Backport from trunk:
authorThomas Heller <theller@ctypes.org>
Wed, 16 Jan 2008 19:24:20 +0000 (19:24 +0000)
committerThomas Heller <theller@ctypes.org>
Wed, 16 Jan 2008 19:24:20 +0000 (19:24 +0000)
  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.

Misc/NEWS
Modules/_ctypes/_ctypes.c

index 04aa21fccf40f5eb07352f874a1bdea79f030a61..77e97f05093c8542b7fadf8d403cc5b84f5f51bb 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,8 +12,6 @@ What's New in Python 2.5.2c1?
 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 @@ Library
 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
index 47fab8a00a54ac318ba1e6c8ea74541342663327..fe772acc5ccb6a8cd219a4dcab2b7a1c160c64b5 100644 (file)
@@ -2896,7 +2896,7 @@ CFuncPtr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
                || 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)