changeset 38042:514605777244

revlog: handle errors from index_node() in nt_insert() and index_slice_del() Same idea as in a9d9802d577e (revlog: don't say "not found" on internal error, 2018-05-04). Differential Revision: https://phab.mercurial-scm.org/D3558
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 11 May 2018 23:28:02 -0700
parents 5fa4e29ba3e3
children d9185fa1e868
files mercurial/cext/revlog.c
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cext/revlog.c	Mon May 14 13:11:04 2018 +0200
+++ b/mercurial/cext/revlog.c	Fri May 11 23:28:02 2018 -0700
@@ -1068,10 +1068,12 @@
 			return 0;
 		}
 		if (v < 0) {
-			const char *oldnode = index_node(self, -(v + 1));
+			const char *oldnode = index_node_existing(self, -(v + 1));
 			int noff;
 
-			if (!oldnode || !memcmp(oldnode, node, 20)) {
+			if (oldnode == NULL)
+				return -1;
+			if (!memcmp(oldnode, node, 20)) {
 				n->children[k] = -rev - 1;
 				return 0;
 			}
@@ -1850,10 +1852,11 @@
 			Py_ssize_t i;
 
 			for (i = start + 1; i < self->length - 1; i++) {
-				const char *node = index_node(self, i);
+				const char *node = index_node_existing(self, i);
+				if (node == NULL)
+					return -1;
 
-				if (node)
-					nt_insert(self, node, -1);
+				nt_insert(self, node, -1);
 			}
 			if (self->added)
 				nt_invalidate_added(self, 0);