Re: [PATCH 01/11] midx.c: clean up chunkfile after reading the MIDX
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 21, 2021, 16:16 UTC
- Message-ID
- <xmqqy26mmjz8.fsf@gitster.g>
- In-Reply-To
- <30f6f23daf49814f479865eea5f9ee68de209d5f.1634787555.git.me@ttaylorr.com>
Taylor Blau <me@ttaylorr.com> writes:
Show 8 quoted lines
> cleanup_fail: > free(m); > free(midx_name); > - free(cf); > + free_chunkfile(cf); > if (midx_map) > munmap(midx_map, midx_size); > if (0 <= fd)
Not a fault of this patch, but I think the code is calling close() on an already closed file descriptor in cleanup_fail codepath, when "goto cleanup_fail" is reached after xmmap() returned, e.g. when oid_version() does not match hash_version, when we failed to read the ToC.
Also, it is not clear why is it a dying offence if we do not find packnames chunk, but it is just a "pretend as if we do not have this midx file and everybody else is happy" when we failed to read the ToC.