changeset 26050:822f46b80fa9

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.
author Augie Fackler <augie@google.com>
date Tue, 18 Aug 2015 16:32:41 -0400
parents b1634b7804c7
children af090796cb33
files mercurial/pathencode.c
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/pathencode.c	Tue Aug 18 16:43:26 2015 -0400
+++ b/mercurial/pathencode.c	Tue Aug 18 16:32:41 2015 -0400
@@ -684,6 +684,8 @@
 
 	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,