Re: [PATCH 5/6] bundle: don't leak an fd in case of early return
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 30, 2016, 17:19 UTC
- Message-ID
- <xmqqio03ubn6.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20160330011743.GD2237@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 9 quoted lines
>> + if (compute_and_write_prerequisites(bundle_fd, &revs, argc, argv)) {
>> + if (!bundle_to_stdout)
>> + close(bundle_fd);
>> return -1;
>> + }
>
> Makes sense. Should we also be rolling back the lock file? It happens
> automatically at program exit, of course, but we are in library code
> here that should not rely on that.Yeah, I agree. I suspect that the original wasn't even meant to be used in a "library-ish" fashion, but as long as we are adding this close(), we should also be doing the rollback.
Thanks.