Skip to content

Commit 3f7d11c

Browse files
committed
Merge branch 'tc/fetch-leak'
* tc/fetch-leak: fetch: plug two leaks on error exit in store_updated_refs Conflicts: builtin/fetch.c
2 parents 6f55f02 + 9516a59 commit 3f7d11c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

builtin/fetch.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,10 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
379379
url = xstrdup("foreign");
380380

381381
rm = ref_map;
382-
if (check_everything_connected(iterate_ref_map, 0, &rm))
383-
return error(_("%s did not send all necessary objects\n"), url);
382+
if (check_everything_connected(iterate_ref_map, 0, &rm)) {
383+
rc = error(_("%s did not send all necessary objects\n"), url);
384+
goto abort;
385+
}
384386

385387
for (rm = ref_map; rm; rm = rm->next) {
386388
struct ref *ref = NULL;
@@ -462,12 +464,15 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
462464
fprintf(stderr, " %s\n", note);
463465
}
464466
}
465-
free(url);
466-
fclose(fp);
467+
467468
if (rc & STORE_REF_ERROR_DF_CONFLICT)
468469
error(_("some local refs could not be updated; try running\n"
469470
" 'git remote prune %s' to remove any old, conflicting "
470471
"branches"), remote_name);
472+
473+
abort:
474+
free(url);
475+
fclose(fp);
471476
return rc;
472477
}
473478

0 commit comments

Comments
 (0)