]> git.proxmox.com Git - libgit2.git/commitdiff
Fix leak in the tests
authorCarlos Martín Nieto <cmn@dwim.me>
Mon, 15 Oct 2012 14:35:10 +0000 (16:35 +0200)
committerCarlos Martín Nieto <cmn@dwim.me>
Mon, 15 Oct 2012 14:35:10 +0000 (16:35 +0200)
Also introduce the slective ref trimming promised but also missed in
the previous commit.

src/refs.c
tests-clar/refs/read.c

index 9e2311b07926f3eb19fbccb63cd8c1e7ad59084d..740d99eda3fd83654bd5f790b44717b7cd764038 100644 (file)
@@ -211,8 +211,6 @@ static int loose_lookup(git_reference *ref)
        if (!updated)
                return 0;
 
-       git_buf_rtrim(&ref_file);
-
        if (ref->flags & GIT_REF_SYMBOLIC) {
                git__free(ref->target.symbolic);
                ref->target.symbolic = NULL;
@@ -222,6 +220,7 @@ static int loose_lookup(git_reference *ref)
 
        if (git__prefixcmp((const char *)(ref_file.ptr), GIT_SYMREF) == 0) {
                ref->flags |= GIT_REF_SYMBOLIC;
+               git_buf_rtrim(&ref_file);
                result = loose_parse_symbolic(ref, &ref_file);
        } else {
                ref->flags |= GIT_REF_OID;
index fc2d6b9023b49d2a106d8a668781e4d5406676a8..c2647e2dbd4b0483102387f79a5095d79bc34eb4 100644 (file)
@@ -212,6 +212,7 @@ void test_refs_read__trailing(void)
        cl_git_pass(git_reference_lookup(&test, g_repo, "refs/heads/test"));
        cl_git_pass(git_reference_lookup(&trailing, g_repo, "refs/heads/trailing"));
        cl_git_pass(git_oid_cmp(git_reference_oid(test), git_reference_oid(trailing)));
+       git_reference_free(trailing);
        cl_git_pass(git_reference_lookup(&trailing, g_repo, "FETCH_HEAD"));
 
        git_reference_free(test);