# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 2015-08-18 20:32:41
# Node ID 822f46b80fa956b71ed3fd366451ad28e2abead8
# Parent  b1634b7804c73f50b4858e8c8cc7b241767d57d2

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.

diff --git a/mercurial/pathencode.c b/mercurial/pathencode.c
--- a/mercurial/pathencode.c
+++ b/mercurial/pathencode.c
@@ -684,6 +684,8 @@ static int sha1hash(char hash[20], const
 
 	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,