Skip to content

Commit 728ae63

Browse files
committed
Merge branch 'tc/bundle-uri-leakfix'
Leakfix. * tc/bundle-uri-leakfix: bundle-uri: plug leak in unbundle_from_file()
2 parents 645cc7a + 6dab49b commit 728ae63

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

bundle-uri.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,17 +368,23 @@ static int unbundle_from_file(struct repository *r, const char *file)
368368
struct strbuf bundle_ref = STRBUF_INIT;
369369
size_t bundle_prefix_len;
370370

371-
if ((bundle_fd = read_bundle_header(file, &header)) < 0)
372-
return 1;
371+
bundle_fd = read_bundle_header(file, &header);
372+
if (bundle_fd < 0) {
373+
result = 1;
374+
goto cleanup;
375+
}
373376

374377
/*
375378
* Skip the reachability walk here, since we will be adding
376379
* a reachable ref pointing to the new tips, which will reach
377380
* the prerequisite commits.
378381
*/
379-
if ((result = unbundle(r, &header, bundle_fd, NULL,
380-
VERIFY_BUNDLE_QUIET | (fetch_pack_fsck_objects() ? VERIFY_BUNDLE_FSCK : 0))))
381-
return 1;
382+
result = unbundle(r, &header, bundle_fd, NULL,
383+
VERIFY_BUNDLE_QUIET | (fetch_pack_fsck_objects() ? VERIFY_BUNDLE_FSCK : 0));
384+
if (result) {
385+
result = 1;
386+
goto cleanup;
387+
}
382388

383389
/*
384390
* Convert all refs/heads/ from the bundle into refs/bundles/
@@ -407,6 +413,8 @@ static int unbundle_from_file(struct repository *r, const char *file)
407413
0, UPDATE_REFS_MSG_ON_ERR);
408414
}
409415

416+
cleanup:
417+
strbuf_release(&bundle_ref);
410418
bundle_header_release(&header);
411419
return result;
412420
}

0 commit comments

Comments
 (0)