summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2008-01-11 19:34:06 (GMT)
committerThomas Heller <theller@ctypes.org>2008-01-11 19:34:06 (GMT)
commitc682614df098700c689eabb47c6857f244e85bed (patch)
treeacec3ccb7364b58a4319b70a6fb010fe60599abf /Modules
parentde680372027df420753d8a2806044f65a75a6e7e (diff)
downloadcpython-c682614df098700c689eabb47c6857f244e85bed.zip
cpython-c682614df098700c689eabb47c6857f244e85bed.tar.gz
cpython-c682614df098700c689eabb47c6857f244e85bed.tar.bz2
Raise an error instead of crashing with a segfault when a NULL
function pointer is called. Will backport to release25-maint.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 212b875..4c4720e 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -3312,6 +3312,11 @@ CFuncPtr_call(CFuncPtrObject *self, PyObject *inargs, PyObject *kwds)
pProc = *(void **)self->b_ptr;
+ if (pProc == NULL) {
+ PyErr_SetString(PyExc_ValueError,
+ "attempt to call NULL function pointer");
+ return NULL;
+ }
#ifdef MS_WIN32
if (self->index) {
/* It's a COM method */