Merge branch 'tc/bundle-uri-leakfix'

Leakfix.

* tc/bundle-uri-leakfix:
  bundle-uri: plug leak in unbundle_from_file()
This commit is contained in:
Taylor Blau
2024-10-18 13:56:24 -04:00

View File

@ -368,17 +368,23 @@ static int unbundle_from_file(struct repository *r, const char *file)
struct strbuf bundle_ref = STRBUF_INIT; struct strbuf bundle_ref = STRBUF_INIT;
size_t bundle_prefix_len; size_t bundle_prefix_len;
if ((bundle_fd = read_bundle_header(file, &header)) < 0) bundle_fd = read_bundle_header(file, &header);
return 1; if (bundle_fd < 0) {
result = 1;
goto cleanup;
}
/* /*
* Skip the reachability walk here, since we will be adding * Skip the reachability walk here, since we will be adding
* a reachable ref pointing to the new tips, which will reach * a reachable ref pointing to the new tips, which will reach
* the prerequisite commits. * the prerequisite commits.
*/ */
if ((result = unbundle(r, &header, bundle_fd, NULL, result = unbundle(r, &header, bundle_fd, NULL,
VERIFY_BUNDLE_QUIET | (fetch_pack_fsck_objects() ? VERIFY_BUNDLE_FSCK : 0)))) VERIFY_BUNDLE_QUIET | (fetch_pack_fsck_objects() ? VERIFY_BUNDLE_FSCK : 0));
return 1; if (result) {
result = 1;
goto cleanup;
}
/* /*
* Convert all refs/heads/ from the bundle into refs/bundles/ * 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)
0, UPDATE_REFS_MSG_ON_ERR); 0, UPDATE_REFS_MSG_ON_ERR);
} }
cleanup:
strbuf_release(&bundle_ref);
bundle_header_release(&header); bundle_header_release(&header);
return result; return result;
} }