parsers: fix memleak of revlog cache entries on strip
Since
12a852c7c763, raw_length can be reduced on strip, but corresponding cache
entries still have refcount. They are not dereferenced by _index_clearcache(),
and never freed.
To reproduce the problem, run "hg pull" and "hg strip null" several times
in the same process.
--- a/mercurial/parsers.c Wed Jan 30 17:32:17 2013 +0100
+++ b/mercurial/parsers.c Mon Jan 28 19:05:35 2013 +0900
@@ -1234,8 +1234,14 @@
self->ntrev = (int)start;
}
self->length = start + 1;
- if (start < self->raw_length)
+ if (start < self->raw_length) {
+ if (self->cache) {
+ Py_ssize_t i;
+ for (i = start; i < self->raw_length; i++)
+ Py_CLEAR(self->cache[i]);
+ }
self->raw_length = start;
+ }
goto done;
}