diff options
author | Larry Hastings <larry@hastings.org> | 2010-02-24 22:49:58 (GMT) |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2010-02-24 22:49:58 (GMT) |
commit | 1373a0781e28a6aaa595ca3ae145ccd586004ac7 (patch) | |
tree | bc89bcbdc3611b3f837c8bdf82c8907eb1a76fcb /Modules | |
parent | 6d726c3a2f105b19b44cba0fdd10646a69cafaaa (diff) | |
download | cpython-1373a0781e28a6aaa595ca3ae145ccd586004ac7.zip cpython-1373a0781e28a6aaa595ca3ae145ccd586004ac7.tar.gz cpython-1373a0781e28a6aaa595ca3ae145ccd586004ac7.tar.bz2 |
Issue #5939: Add additional runtime checking to ensure a valid capsule
in Modules/_ctypes/callproc.c. Reviewed by Benjamin P. My first commit!
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/callproc.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index f5eaa0d..2a75fb1 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -139,8 +139,14 @@ _ctypes_get_errobj(int **pspace) return NULL; } errobj = PyDict_GetItem(dict, error_object_name); - if (errobj) + if (errobj) { + if (!PyCapsule_IsValid(errobj, CTYPES_CAPSULE_NAME_PYMEM)) { + PyErr_SetString(PyExc_RuntimeError, + "ctypes.error_object is an invalid capsule"); + return NULL; + } Py_INCREF(errobj); + } else { void *space = PyMem_Malloc(sizeof(int) * 2); if (space == NULL) |