# HG changeset patch # User Martin von Zweigbergk # Date 1526106482 25200 # Node ID 514605777244de61b68c7e1503c4f106773913f4 # Parent 5fa4e29ba3e30ca47f66c79b9aabc3f5fe19ee5e 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 diff -r 5fa4e29ba3e3 -r 514605777244 mercurial/cext/revlog.c --- 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);