From: Oren Milman Date: Sun, 24 Sep 2017 09:21:42 +0000 (+0300) Subject: bpo-31311: Impove error reporting in case the first argument to PyCData_setstate... X-Git-Tag: v3.7.0a2~126 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4facdf523aa6967487a9425f124da9661b59fd43;p=thirdparty%2FPython%2Fcpython.git bpo-31311: Impove error reporting in case the first argument to PyCData_setstate() isn't a dictionary. (#3255) --- diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 1942c63c8153..8afb8cc1f161 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -2665,8 +2665,11 @@ PyCData_setstate(PyObject *myself, PyObject *args) int res; PyObject *dict, *mydict; CDataObject *self = (CDataObject *)myself; - if (!PyArg_ParseTuple(args, "Os#", &dict, &data, &len)) + if (!PyArg_ParseTuple(args, "O!s#", + &PyDict_Type, &dict, &data, &len)) + { return NULL; + } if (len > self->b_size) len = self->b_size; memmove(self->b_ptr, data, len);