Paul Eggert <[EMAIL PROTECTED]> writes:

> Simon Josefsson <[EMAIL PROTECTED]> writes:
>
>> --- read-file.c      16 Jun 2006 21:26:36 +0200      1.1
>> +++ read-file.c      17 Jun 2006 18:22:29 +0200      
>> @@ -43,6 +43,9 @@
>>    if (!buf)
>>      return NULL;
>>  
>> +  if (ferror (stream))
>> +    return NULL;
>> +
>>    while (!feof (stream))
>>      {
>>        size_t count;
>
> But that would leak memory and would cause errno to contain junk on
> failure, even on a POSIX host.
>
> How about the following patch instead?  It fixes a few other minor
> glitches I spotted.  I think it addresses Larry Jones's objections as
> well, since it causes the code to always invoke 'read'; on hosts
> conforming to the C Standard this is fine, and on other hosts where
> feof/ferror isn't sticky, the usual convention is to retry the read
> anyway, so it's better in that case.  I haven't tested it, though.

I've tested it briefly, and it seems to work, so I installed it.
Thanks!

/Simon


Reply via email to