Merge branch 'lp/http-fetch-pack-index-leak-fix' into jch

A memory leak in `fetch_and_setup_pack_index()` when verification of
the downloaded pack index fails has been plugged. Also an obsolete
`unlink()` call on parse failure has been cleaned up.

* lp/http-fetch-pack-index-leak-fix:
  http: fix memory leak in fetch_and_setup_pack_index()
  http: cleanup function fetch_and_setup_pack_index()
This commit is contained in:
Junio C Hamano
2026-06-04 08:13:55 +09:00

10
http.c
View File

@@ -2609,18 +2609,18 @@ static int fetch_and_setup_pack_index(struct packfile_list *packs,
new_pack = parse_pack_index(the_repository, sha1, tmp_idx);
if (!new_pack) {
unlink(tmp_idx);
free(tmp_idx);
return -1; /* parse_pack_index() already issued error message */
}
ret = verify_pack_index(new_pack);
if (!ret)
close_pack_index(new_pack);
close_pack_index(new_pack);
free(tmp_idx);
if (ret)
if (ret) {
free(new_pack);
return -1;
}
packfile_list_prepend(packs, new_pack);
return 0;