cext-index: propagate inline_scan error in `index_deref` stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 12 Mar 2020 15:23:47 +0100
branchstable
changeset 44500 864e9534d3d4
parent 44499 daf083140b5b
child 44559 bc9a9016467d
cext-index: propagate inline_scan error in `index_deref` Before this change, revlog index corruption could be silently ignored in some situation. Differential Revision: https://phab.mercurial-scm.org/D8276
mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c	Thu Mar 12 18:53:37 2020 +0100
+++ b/mercurial/cext/revlog.c	Thu Mar 12 15:23:47 2020 +0100
@@ -157,7 +157,10 @@
 			                             sizeof(*self->offsets));
 			if (self->offsets == NULL)
 				return (const char *)PyErr_NoMemory();
-			inline_scan(self, self->offsets);
+			Py_ssize_t ret = inline_scan(self, self->offsets);
+			if (ret == -1) {
+				return NULL;
+			};
 		}
 		return self->offsets[pos];
 	}