builtin/fetch.c: don't free remote->name after fetch

Make fetch's string_list of remote names own all of its string items (strdup'ing when necessary) so that it can deallocate them safely when clearing. Signed-off-by: Keith McGuigan <kmcguigan@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Keith McGuigan committed Jun 14, 2016 at 14:28 UTC b7410f616ea938ab34816b04e0479d55877af511
1 file changed +2 -4
builtin/fetch.c
+2 -4
@@ -1005,7 +1005,7 @@ static int get_remote_group(const char *key, const char *value, void *priv)
1005 size_t wordlen = strcspn(value, " \t\n");
1006
1007 if (wordlen >= 1)
1008 - string_list_append(g->list,
1008 + string_list_append_nodup(g->list,
1009 xstrndup(value, wordlen));
1010 value += wordlen + (value[wordlen] != '\0');
1011 }
@@ -1143,7 +1143,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
1143 int cmd_fetch(int argc, const char **argv, const char *prefix)
1144 {
1145 int i;
1146 - struct string_list list = STRING_LIST_INIT_NODUP;
1146 + struct string_list list = STRING_LIST_INIT_DUP;
1147 struct remote *remote;
1148 int result = 0;
1149 struct argv_array argv_gc_auto = ARGV_ARRAY_INIT;
@@ -1226,8 +1226,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
1226 argv_array_clear(&options);
1227 }
1228
1229 - /* All names were strdup()ed or strndup()ed */
1230 - list.strdup_strings = 1;
1229 string_list_clear(&list, 0);
1230
1231 close_all_packs();