pathencode: check result of .digest() method in sha1hash

Without this it was theoretically possible .digest() would fail and
return NULL but we wouldn't notice. Detected with cpychecker.
This commit is contained in:
Augie Fackler 2015-08-18 16:32:41 -04:00
parent d203bdeed3
commit f28f2e0f50

View File

@ -684,6 +684,8 @@ static int sha1hash(char hash[20], const char *str, Py_ssize_t len)
hashobj = PyObject_CallMethod(shaobj, "digest", "");
Py_DECREF(shaobj);
if (hashobj == NULL)
return -1;
if (!PyString_Check(hashobj) || PyString_GET_SIZE(hashobj) != 20) {
PyErr_SetString(PyExc_TypeError,