diff mercurial/parsers.c @ 18504:d1d5fdcc2d46 stable

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.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 28 Jan 2013 19:05:35 +0900
parents 0459c6555f69
children 194e63c1ccb9
line wrap: on
line diff
--- 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;
 	}