Commit 3451c871cb81310cefa41cae8e0e76a4944428a5

Edward Thomson 2015-06-30T09:29:41

Merge pull request #3271 from jeffhostetler/more_leaks memory leak refspec.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/src/refspec.c b/src/refspec.c
index 961f939..f92a6d2 100644
--- a/src/refspec.c
+++ b/src/refspec.c
@@ -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)