fetch: plug two leaks on error exit in store_updated_refs
Close FETCH_HEAD and release the string url even if we have to leave the function store_updated_refs() early. Reported-by: Chris Wilson <cwilson@vigilantsw.com> Helped-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
6b67e0dc06
commit
9516a598e3
@ -423,8 +423,10 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
|
|||||||
else
|
else
|
||||||
url = xstrdup("foreign");
|
url = xstrdup("foreign");
|
||||||
|
|
||||||
if (check_everything_connected(ref_map, 0))
|
if (check_everything_connected(ref_map, 0)) {
|
||||||
return error(_("%s did not send all necessary objects\n"), url);
|
rc = error(_("%s did not send all necessary objects\n"), url);
|
||||||
|
goto abort;
|
||||||
|
}
|
||||||
|
|
||||||
for (rm = ref_map; rm; rm = rm->next) {
|
for (rm = ref_map; rm; rm = rm->next) {
|
||||||
struct ref *ref = NULL;
|
struct ref *ref = NULL;
|
||||||
@ -506,12 +508,15 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
|
|||||||
fprintf(stderr, " %s\n", note);
|
fprintf(stderr, " %s\n", note);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(url);
|
|
||||||
fclose(fp);
|
|
||||||
if (rc & STORE_REF_ERROR_DF_CONFLICT)
|
if (rc & STORE_REF_ERROR_DF_CONFLICT)
|
||||||
error(_("some local refs could not be updated; try running\n"
|
error(_("some local refs could not be updated; try running\n"
|
||||||
" 'git remote prune %s' to remove any old, conflicting "
|
" 'git remote prune %s' to remove any old, conflicting "
|
||||||
"branches"), remote_name);
|
"branches"), remote_name);
|
||||||
|
|
||||||
|
abort:
|
||||||
|
free(url);
|
||||||
|
fclose(fp);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user