summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-07-07 08:41:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-07-07 16:00:31 (GMT)
commit8aae3cf7558f00cf3c05636f888cb11e5e548e51 (patch)
treefdb34e2eeb8010b9eb91784bdbddec0ff49b2113 /t
parent75afe7ac8728128873c001d82b02ada4a3aa8181 (diff)
downloadgit-8aae3cf7558f00cf3c05636f888cb11e5e548e51.zip
git-8aae3cf7558f00cf3c05636f888cb11e5e548e51.tar.gz
git-8aae3cf7558f00cf3c05636f888cb11e5e548e51.tar.bz2
reflog-walk: don't free reflogs added to cache
The add_reflog_for_walk() function keeps a cache mapping refnames to their reflog contents. We use a cached reflog entry if available, and otherwise allocate and store a new one. Since 5026b47175 (add_reflog_for_walk: avoid memory leak, 2017-05-04), when we hit an error parsing a date-based reflog spec, we free the reflog memory but leave the cache entry pointing to the now-freed memory. We can fix this by just leaving the memory intact once it has made it into the cache. This may leave an unused entry in the cache, but that's OK. And it means we also catch a similar situation: we may not have allocated at all in this invocation, but simply be pointing to a cached entry from a previous invocation (which is relying on that entry being present). The new test in t1411 exercises this case and fails when run with --valgrind or ASan. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t1411-reflog-show.sh4
1 files changed, 4 insertions, 0 deletions
diff --git a/t/t1411-reflog-show.sh b/t/t1411-reflog-show.sh
index ae96eeb..b9cb766 100755
--- a/t/t1411-reflog-show.sh
+++ b/t/t1411-reflog-show.sh
@@ -177,4 +177,8 @@ test_expect_success 'showing multiple reflogs works' '
git log -g HEAD HEAD >actual
'
+test_expect_success 'showing multiple reflogs with an old date' '
+ git log -g HEAD@{1979-01-01} HEAD >actual
+'
+
test_done