summaryrefslogtreecommitdiff
path: root/Modules/_ctypes
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2019-09-12 04:09:32 -0600
committerBenjamin Peterson <benjamin@python.org>2019-09-12 11:09:32 +0100
commitea683deccc505a78bbbb1eb8c6a88b0835ad5151 (patch)
treed56dadd7c576988c08b3fe763b84ffa77c4ae40f /Modules/_ctypes
parent954900a3f98a8c0dea14dd575490237f3f8626b3 (diff)
downloadcpython-git-ea683deccc505a78bbbb1eb8c6a88b0835ad5151.tar.gz
closes bpo-38127: _ctypes: PyObject_IsSubclass() should be checked for failure. (GH-16011)
An exception may occur during a PyObject_IsSubclass() call.
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r--Modules/_ctypes/_ctypes.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index d2f6391fa6..16a0cfe8dd 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -1168,7 +1168,11 @@ PyCPointerType_from_param(PyObject *type, PyObject *value)
*/
StgDictObject *v = PyObject_stgdict(value);
assert(v); /* Cannot be NULL for pointer or array objects */
- if (PyObject_IsSubclass(v->proto, typedict->proto)) {
+ int ret = PyObject_IsSubclass(v->proto, typedict->proto);
+ if (ret < 0) {
+ return NULL;
+ }
+ if (ret) {
Py_INCREF(value);
return value;
}