closes bpo-38127: _ctypes: PyObject_IsSubclass() should be checked for failure. (GH-16011)

An exception may occur during a PyObject_IsSubclass() call.
(cherry picked from commit ea683deccc)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
This commit is contained in:
Miss Islington (bot) 2019-09-12 03:30:55 -07:00 committed by GitHub
parent ff2a5c0204
commit 197ac1ad1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -1094,7 +1094,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;
}