path: root/remote.h
diff options
authorBrandon Casey <>2008-08-22 00:16:30 (GMT)
committerJunio C Hamano <>2008-08-22 07:15:37 (GMT)
commit2cb1f36d5098060a4bac182da16ceed3197a57c2 (patch)
treef307204f169aec5535a89c246f79f7df537190c0 /remote.h
parenta9da1663dfc869141749c768e9e0f52bb48218e3 (diff)
remote.c: add a function for deleting a refspec array and use it (twice)
A number of call sites allocate memory for a refspec array, populate its members with heap memory, and then free only the refspec pointer while leaking the memory allocated for the member elements. Provide a function for freeing the elements of a refspec array and the array itself. Caution to callers: code paths must be checked to ensure that the refspec members "src" and "dst" can be passed to free. Signed-off-by: Brandon Casey <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'remote.h')
1 files changed, 1 insertions, 0 deletions
diff --git a/remote.h b/remote.h
index 091b1d0..2601f6e 100644
--- a/remote.h
+++ b/remote.h
@@ -78,6 +78,7 @@ void ref_remove_duplicates(struct ref *ref_map);
int valid_fetch_refspec(const char *refspec);
struct refspec *parse_fetch_refspec(int nr_refspec, const char **refspec);
struct refspec *parse_push_refspec(int nr_refspec, const char **refspec);
+void free_refspecs(struct refspec *refspec, int nr_refspec);
int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
int nr_refspec, const char **refspec, int all);