Commit 8fa0b34b by Etienne Samson Committed by Patrick Steinhardt

local: fix a leaking reference when iterating over a symref


Valgrind log :

==17702== 18 bytes in 1 blocks are indirectly lost in loss record 69 of 1,123
==17702==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==17702==    by 0x5FDBB49: strdup (strdup.c:42)
==17702==    by 0x632B3E: git__strdup (util.h:106)
==17702==    by 0x632D2C: git_reference__alloc_symbolic (refs.c:64)
==17702==    by 0x62E0AF: loose_lookup (refdb_fs.c:408)
==17702==    by 0x62E636: refdb_fs_backend__iterator_next (refdb_fs.c:565)
==17702==    by 0x62CD8E: git_refdb_iterator_next (refdb.c:147)
==17702==    by 0x6347F2: git_reference_next (refs.c:838)
==17702==    by 0x6345CB: git_reference_foreach (refs.c:748)
==17702==    by 0x66BE62: local_download_pack (local.c:579)
==17702==    by 0x5DB48F: git_fetch_download_pack (fetch.c:148)
==17702==    by 0x639028: git_remote_download (remote.c:932)
==17702==    by 0x63919A: git_remote_fetch (remote.c:969)
==17702==    by 0x4ABEDD: test_fetchhead_nonetwork__fetch_into_repo_with_symrefs (nonetwork.c:362)
==17702==    by 0x4125D9: clar_run_test (clar.c:222)
==17702==    by 0x41287C: clar_run_suite (clar.c:286)
==17702==    by 0x412DDE: clar_test_run (clar.c:433)
==17702==    by 0x4105E1: main (main.c:24)
parent 2fe887e6
...@@ -512,8 +512,10 @@ static int foreach_reference_cb(git_reference *reference, void *payload) ...@@ -512,8 +512,10 @@ static int foreach_reference_cb(git_reference *reference, void *payload)
git_revwalk *walk = (git_revwalk *)payload; git_revwalk *walk = (git_revwalk *)payload;
int error; int error;
if (git_reference_type(reference) != GIT_REF_OID) if (git_reference_type(reference) != GIT_REF_OID) {
git_reference_free(reference);
return 0; return 0;
}
error = git_revwalk_hide(walk, git_reference_target(reference)); error = git_revwalk_hide(walk, git_reference_target(reference));
/* The reference is in the local repository, so the target may not /* The reference is in the local repository, so the target may not
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment