[PATCH stable] parsers: fix memleak of revlog cache entries on strip
Yuya Nishihara
yuya at tcha.org
Mon Jan 28 05:23:41 CST 2013
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1359367535 -32400
# Branch stable
# Node ID 3be44e46f01bb9777cbb486bea6e52617fc05efa
# Parent 692cbda1eb50fe30c70792cb1e9380b28769467c
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;
}
More information about the Mercurial-devel
mailing list