summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorLarry Hastings <larry@hastings.org>2010-02-24 22:49:58 (GMT)
committerLarry Hastings <larry@hastings.org>2010-02-24 22:49:58 (GMT)
commit1373a0781e28a6aaa595ca3ae145ccd586004ac7 (patch)
treebc89bcbdc3611b3f837c8bdf82c8907eb1a76fcb /Modules
parent6d726c3a2f105b19b44cba0fdd10646a69cafaaa (diff)
downloadcpython-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.c8
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)