parsers: fix refcount bug on corrupt index stable
authorMatt Mackall <mpm@selenic.com>
Mon, 07 May 2012 15:40:50 -0500
branchstable
changeset 16597 b767382a8675
parent 16596 95ca6c8b38da
child 16598 20a9d823f242
parsers: fix refcount bug on corrupt index When we encounter a corrupt index, we "fail" the init but our destructor still gets called. On some systems, this was causing us to attempt to decref a dangling to self->data.
mercurial/parsers.c
--- a/mercurial/parsers.c	Fri May 04 14:19:55 2012 +0200
+++ b/mercurial/parsers.c	Mon May 07 15:40:50 2012 -0500
@@ -983,6 +983,7 @@
 	self->ntdepth = self->ntsplits = 0;
 	self->ntlookups = self->ntmisses = 0;
 	self->ntrev = -1;
+	Py_INCREF(self->data);
 
 	if (self->inlined) {
 		long len = inline_scan(self, NULL);
@@ -998,7 +999,6 @@
 		self->raw_length = size / 64;
 		self->length = self->raw_length + 1;
 	}
-	Py_INCREF(self->data);
 
 	return 0;
 bail: