Skip to content

Commit

Permalink
Free the path_lists used to find non-local tags in git-fetch
Browse files Browse the repository at this point in the history
To support calling find_non_local_tags() more than once in a single
git-fetch process we need the existing_refs to be stack-allocated
so it resets on the second call.  We also should free the path
lists to avoid unnecessary memory leaking.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Shawn O. Pearce authored and Junio C Hamano committed Mar 3, 2008
1 parent c50b2b4 commit 49d58fd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion builtin-fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ static void find_non_local_tags(struct transport *transport,
struct ref **head,
struct ref ***tail)
{
static struct path_list existing_refs = { NULL, 0, 0, 0 };
struct path_list existing_refs = { NULL, 0, 0, 0 };
struct path_list new_refs = { NULL, 0, 0, 1 };
char *ref_name;
int ref_name_len;
Expand Down Expand Up @@ -503,6 +503,8 @@ static void find_non_local_tags(struct transport *transport,
}
free(ref_name);
}
path_list_clear(&existing_refs, 0);
path_list_clear(&new_refs, 0);
}

static int do_fetch(struct transport *transport,
Expand Down

0 comments on commit 49d58fd

Please sign in to comment.