# HG changeset patch # User Matt Mackall # Date 2012-05-07 20:40:50 # Node ID b767382a8675117f62b162d2864f77e140861bef # Parent 95ca6c8b38da95c065d6454dad775c7ba24e91db 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. diff --git a/mercurial/parsers.c b/mercurial/parsers.c --- a/mercurial/parsers.c +++ b/mercurial/parsers.c @@ -983,6 +983,7 @@ static int index_init(indexObject *self, 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 @@ static int index_init(indexObject *self, self->raw_length = size / 64; self->length = self->raw_length + 1; } - Py_INCREF(self->data); return 0; bail: