Commit 07a2a1b7 authored by Christian Heimes's avatar Christian Heimes

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
parent 884332b4
...@@ -4263,7 +4263,7 @@ reduce_newobj(PyObject *obj) ...@@ -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) ...@@ -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));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment