summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2008-01-11 20:29:19 (GMT)
committerThomas Heller <theller@ctypes.org>2008-01-11 20:29:19 (GMT)
commit43617bc610a92d0025a9c9473fdbe0d81c51fd4d (patch)
treeffc9a48f97e1098c96b6a87e0f607cd30dbf5e0d
parentc682614df098700c689eabb47c6857f244e85bed (diff)
downloadcpython-43617bc610a92d0025a9c9473fdbe0d81c51fd4d.zip
cpython-43617bc610a92d0025a9c9473fdbe0d81c51fd4d.tar.gz
cpython-43617bc610a92d0025a9c9473fdbe0d81c51fd4d.tar.bz2
Fix a potential 'SystemError: NULL result without error'.
NULL may be a valid return value from PyLong_AsVoidPtr. Will backport to release25-maint.
-rw-r--r--Modules/_ctypes/_ctypes.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 4c4720e..1e0f963 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -2899,7 +2899,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)