# HG changeset patch # User Yuya Nishihara # Date 2013-01-28 10:05:35 # Node ID d1d5fdcc2d46d5559ec0e38fe6530b1f93c07f79 # Parent 7f769d3a8ad241d689a3011fb21f4b04f84f3712 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. diff --git a/mercurial/parsers.c b/mercurial/parsers.c --- a/mercurial/parsers.c +++ b/mercurial/parsers.c @@ -1234,8 +1234,14 @@ static int index_slice_del(indexObject * 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; }