On Wed, Jul 01, 2026 at 07:04:19AM +0000, Johannes Schindelin via GitGitGadget wrote:
quoted hunk ↗ jump to hunk
diff --git a/loose.c b/loose.c
index 0b626c1b85..47b7f5ec38 100644
--- a/loose.c
+++ b/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);@@ -98,13 +99,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 = 0;
err:
+ fclose(fp);
strbuf_release(&buf);
strbuf_release(&path);
- return -1;
+ return ret;
}
Makes sense. There's no `goto err` before we assign `fp`, and when the
call to `fopen()` fails we return via a different path. So the added
call to `fclose(fp)` is fine.
Patrick