mirror of
https://github.com/python/cpython.git
synced 2025-09-13 04:08:37 +00:00
Issue #5939: Add additional runtime checking to ensure a valid capsule
in Modules/_ctypes/callproc.c. Reviewed by Benjamin P. My first commit!
This commit is contained in:
parent
6d726c3a2f
commit
1373a0781e
2 changed files with 10 additions and 1 deletions
|
@ -12,6 +12,9 @@ What's New in Python 3.2 Alpha 1?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #5939: Add additional runtime checking to ensure a valid capsule
|
||||||
|
in Modules/_ctypes/callproc.c.
|
||||||
|
|
||||||
- Issue #7309: Fix unchecked attribute access when converting
|
- Issue #7309: Fix unchecked attribute access when converting
|
||||||
UnicodeEncodeError, UnicodeDecodeError, and UnicodeTranslateError to
|
UnicodeEncodeError, UnicodeDecodeError, and UnicodeTranslateError to
|
||||||
strings.
|
strings.
|
||||||
|
|
|
@ -139,8 +139,14 @@ _ctypes_get_errobj(int **pspace)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
errobj = PyDict_GetItem(dict, error_object_name);
|
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);
|
Py_INCREF(errobj);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
void *space = PyMem_Malloc(sizeof(int) * 2);
|
void *space = PyMem_Malloc(sizeof(int) * 2);
|
||||||
if (space == NULL)
|
if (space == NULL)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue