[PATCH 3 of 6 lazymanifest-errors] lazymanifest: check more error returns in setitem

Augie Fackler raf at durin42.com
Thu Dec 31 13:05:47 CST 2015


# HG changeset patch
# User Augie Fackler <raf at durin42.com>
# Date 1451587462 18000
#      Thu Dec 31 13:44:22 2015 -0500
# Node ID 137312daf44138dfe05826e7d928e345acf62a72
# Parent  2cde05d091f1e053f4cf57db579acdd98b8935cf
lazymanifest: check more error returns in setitem

diff --git a/mercurial/manifest.c b/mercurial/manifest.c
--- a/mercurial/manifest.c
+++ b/mercurial/manifest.c
@@ -500,6 +500,9 @@ static int lazymanifest_setitem(
 	}
 
 	pyhash = PyTuple_GetItem(value, 0);
+	if (!pyhash) {
+		return -1;
+	}
 	if (!PyString_Check(pyhash)) {
 		PyErr_Format(PyExc_TypeError,
 			     "node must be a 20-byte string");
@@ -518,8 +521,14 @@ static int lazymanifest_setitem(
 		return -1;
 	}
 	hash = PyString_AsString(pyhash);
+	if (!hash) {
+		return -1;
+	}
 
 	pyflags = PyTuple_GetItem(value, 1);
+	if (!pyflags) {
+		return -1;
+	}
 	if (!PyString_Check(pyflags) || PyString_Size(pyflags) > 1) {
 		PyErr_Format(PyExc_TypeError,
 			     "flags must a 0 or 1 byte string");


More information about the Mercurial-devel mailing list