[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a minor bug

From: James Youngman
Subject: Re: a minor bug
Date: Wed, 23 Dec 2015 23:25:33 +0000

On Wed, Dec 23, 2015 at 11:13 PM, Paul Eggert <address@hidden> wrote:
> James Youngman wrote:
>> +static FILE* fopen_cloexec_for_read_only (const char *file_name) {
>> +  int fd = open_cloexec (file_name, O_RDONLY);
>> +  return (fd < 0) ? NULL : fdopen (fd, "r");
>> +}
> This should close fd if fdopen fails, no?

Ouch, I leaked an fd in code intended to avoid that.

> Also, the indentation should be fixed to be GNU-like.

Thanks, I fixed both problems in the attached patch.   This is a sign
I should stop working for the day, probably; my attention to detail
has fallen off.  Thanks for spotting the problems.


Attachment: 0001-Avoid-an-fd-leak-in-fopen_cloexec_for_read_only.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]