Additional safe-guard against dereferencing NULL in reduce_newobj

_PyObject_GetNewArguments() can leave args == NULL but the __newobj_ex__
branch expects args to be not-NULL.

CID 1353201
This commit is contained in:
Christian Heimes 2016-09-09 00:21:22 +02:00
parent 884332b45a
commit 07a2a1b7e5
1 changed files with 7 additions and 1 deletions

View File

@ -4263,7 +4263,7 @@ reduce_newobj(PyObject *obj)
} }
Py_XDECREF(args); Py_XDECREF(args);
} }
else { else if (args != NULL) {
_Py_IDENTIFIER(__newobj_ex__); _Py_IDENTIFIER(__newobj_ex__);
newobj = _PyObject_GetAttrId(copyreg, &PyId___newobj_ex__); newobj = _PyObject_GetAttrId(copyreg, &PyId___newobj_ex__);
@ -4281,6 +4281,12 @@ reduce_newobj(PyObject *obj)
return NULL; return NULL;
} }
} }
else {
/* args == NULL */
Py_DECREF(kwargs);
PyErr_BadInternalCall();
return NULL;
}
state = _PyObject_GetState(obj, state = _PyObject_GetState(obj,
!hasargs && !PyList_Check(obj) && !PyDict_Check(obj)); !hasargs && !PyList_Check(obj) && !PyDict_Check(obj));