]> git.proxmox.com Git - libgit2.git/commitdiff
fix memory leak in refspec.c on errors.
authorJeff Hostetler <jeffhost@microsoft.com>
Mon, 29 Jun 2015 21:32:22 +0000 (17:32 -0400)
committerJeff Hostetler <jeffhost@microsoft.com>
Tue, 30 Jun 2015 13:41:17 +0000 (09:41 -0400)
src/refspec.c

index 961f939c6af672d48239494a964648839aa23672..f92a6d2b61776260624dbe30bd7f85aa7d335cca 100644 (file)
@@ -142,6 +142,7 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
         giterr_set(
                 GITERR_INVALID,
                 "'%s' is not a valid refspec.", input);
+        git_refspec__free(refspec);
        return -1;
 }
 
@@ -153,6 +154,8 @@ void git_refspec__free(git_refspec *refspec)
        git__free(refspec->src);
        git__free(refspec->dst);
        git__free(refspec->string);
+
+       memset(refspec, 0x0, sizeof(git_refspec));
 }
 
 const char *git_refspec_src(const git_refspec *refspec)