Subject: Re: [PATCH v5 1/5] setup: add gentle version of read_gitfile

From: Junio C Hamano <[email-masked]>
Date: Wed, 29 Apr 2015 18:35:09 -0700

Stefan Beller <[email-masked]> writes:

[administrivia: cull the parts of the original from your quote if
you are not addressing them]

>>         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.