diff --git a/bundle.c b/bundle.c index f18f98fec9c1f4..d7ad6908433ecf 100644 --- a/bundle.c +++ b/bundle.c @@ -607,8 +607,10 @@ int unbundle(struct repository *r, struct bundle_header *header, if (!opts) opts = &opts_fallback; - if (verify_bundle(r, header, opts->flags)) + if (verify_bundle(r, header, opts->flags)) { + close(bundle_fd); return -1; + } strvec_pushl(&ip.args, "index-pack", "--fix-thin", "--stdin", NULL); diff --git a/bundle.h b/bundle.h index a80aa8ad9bf9df..d664b2f2d61e20 100644 --- a/bundle.h +++ b/bundle.h @@ -62,6 +62,8 @@ struct unbundle_opts { * * Before unbundling, this method will call verify_bundle() with 'flags' * provided in 'opts'. + * + * Note that the `bundle_fd` will be closed as part of the operation. */ int unbundle(struct repository *r, struct bundle_header *header, int bundle_fd, struct strvec *extra_index_pack_args, diff --git a/transport.c b/transport.c index 10d820c33353f6..eb808f1e4b776d 100644 --- a/transport.c +++ b/transport.c @@ -207,6 +207,7 @@ static int fetch_refs_from_bundle(struct transport *transport, ret = unbundle(the_repository, &data->header, data->fd, &extra_index_pack_args, &opts); + data->fd = -1; /* `unbundle()` closes the file descriptor */ transport->hash_algo = data->header.hash_algo; strvec_clear(&extra_index_pack_args);