mirror of
https://github.com/git/git.git
synced 2026-08-05 23:51:27 +00:00
load_one_loose_object_map(): fix resource leak
Pointed out by Coverity. While at it, reduce near-duplicate clean-up code at the end of the function. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
e9019fcafe
commit
8b90835161
9
loose.c
9
loose.c
@@ -65,6 +65,7 @@ static int load_one_loose_object_map(struct repository *repo, struct odb_source_
|
||||
{
|
||||
struct strbuf buf = STRBUF_INIT, path = STRBUF_INIT;
|
||||
FILE *fp;
|
||||
int ret = -1;
|
||||
|
||||
if (!loose->map)
|
||||
loose_object_map_init(&loose->map);
|
||||
@@ -84,7 +85,6 @@ static int load_one_loose_object_map(struct repository *repo, struct odb_source_
|
||||
return 0;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
if (strbuf_getwholeline(&buf, fp, '\n') || strcmp(buf.buf, loose_object_header))
|
||||
goto err;
|
||||
while (!strbuf_getline_lf(&buf, fp)) {
|
||||
@@ -98,13 +98,12 @@ static int load_one_loose_object_map(struct repository *repo, struct odb_source_
|
||||
insert_loose_map(loose, &oid, &compat_oid);
|
||||
}
|
||||
|
||||
strbuf_release(&buf);
|
||||
strbuf_release(&path);
|
||||
return errno ? -1 : 0;
|
||||
ret = ferror(fp) ? -1 : 0;
|
||||
err:
|
||||
fclose(fp);
|
||||
strbuf_release(&buf);
|
||||
strbuf_release(&path);
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int repo_read_loose_object_map(struct repository *repo)
|
||||
|
||||
Reference in New Issue
Block a user