[PATCH 7 of 8] parsers: ensure that nullid is always present in the radix tree

Bryan O'Sullivan bos at serpentine.com
Tue May 8 17:00:10 CDT 2012


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1336513792 25200
# Node ID 8303271d842b99b43d95d8938d316d17c302f716
# Parent  97fd1ecc3dd0602b58c8ffc4daa09588e5cfd909
parsers: ensure that nullid is always present in the radix tree

diff -r 97fd1ecc3dd0 -r 8303271d842b mercurial/parsers.c
--- a/mercurial/parsers.c	Tue May 08 14:49:07 2012 -0700
+++ b/mercurial/parsers.c	Tue May 08 14:49:52 2012 -0700
@@ -387,7 +387,7 @@
 	Py_ssize_t length = index_length(self);
 	const char *data;
 
-	if (pos == length - 1)
+	if (pos == length - 1 || pos == INT_MAX)
 		return nullid;
 
 	if (pos >= length)
@@ -671,6 +671,8 @@
 		self->ntrev = (int)index_length(self) - 1;
 		self->ntlookups = 1;
 		self->ntmisses = 0;
+		if (nt_insert(self, nullid, INT_MAX) == -1)
+			return -1;
 	}
 	return 0;
 }


More information about the Mercurial-devel mailing list