Commit 64e6b5b0 by Jeff Hostetler

fix memory leak in refspec.c on errors.

parent 4a0313bc
...@@ -142,6 +142,7 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch) ...@@ -142,6 +142,7 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
giterr_set( giterr_set(
GITERR_INVALID, GITERR_INVALID,
"'%s' is not a valid refspec.", input); "'%s' is not a valid refspec.", input);
git_refspec__free(refspec);
return -1; return -1;
} }
...@@ -153,6 +154,8 @@ void git_refspec__free(git_refspec *refspec) ...@@ -153,6 +154,8 @@ void git_refspec__free(git_refspec *refspec)
git__free(refspec->src); git__free(refspec->src);
git__free(refspec->dst); git__free(refspec->dst);
git__free(refspec->string); git__free(refspec->string);
memset(refspec, 0x0, sizeof(git_refspec));
} }
const char *git_refspec_src(const git_refspec *refspec) const char *git_refspec_src(const git_refspec *refspec)
......
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