Re: [PATCH v5 1/5] setup: add gentle version of read_gitfile
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 30, 2015, 01:35 UTC
- Message-ID
- <xmqq383i4cvm.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <CAGZ79kY95mxKWwTPSB0S5c0eux1ButhuvGz91GQUz8WXt1w18w@mail.gmail.com>
Stefan Beller <sbeller@google.com> writes:
[administrivia: cull the parts of the original from your quote if you are not addressing them]
Show 20 quoted lines
>> fd = open(path, O_RDONLY);
>> - if (fd < 0)
>> - die_errno("Error opening '%s'", path);
>> + if (fd < 0) {
>> + error_code = READ_GITFILE_ERR_OPEN_FAILED;
>> + goto cleanup_return;
>> + }
>> buf = xmalloc(st.st_size + 1);
>> len = read_in_full(fd, buf, st.st_size);
>> close(fd);
>> - if (len != st.st_size)
>> - die("Error reading %s", path);
>> + if (len != st.st_size) {
>> + error_code = READ_GITFILE_ERR_READ_FAILED;
>> + goto cleanup_return;
>
> Sorry for the late review.
>
> So when you jump from here to the cleanup, there is no close(fd) involved?
> I think there are code paths now, which leak fd.This one comes _after_ close(fd), so there is no issue.
A later step does introduce an issue; see $gmane/267975.
Thanks.