Skip to contentSkip to conversation

Free the path_lists used to find non-local tags in git-fetch

PATCH New Shawn O. Pearce 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v3 5/8 Free the path_lists used to find non-local tags in git-fetch

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.

---
 builtin-fetch.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
builtin-fetch.c +3 -1
index 1d3ce77..3758d48 100644
@@ -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;
@@ -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,
Signature · 1 line
1.5.4.3.468.g36990