[PATCH] vfprintf: Fix memory with large width and precision [BZ #19931]

Florian Weimer fweimer@redhat.com
Mon Apr 11 16:02:00 GMT 2016


On 04/11/2016 05:52 PM, Paul Eggert wrote:
> On 04/11/2016 08:18 AM, Florian Weimer wrote:
>> +      /* Deallocate any previously allocated buffer because it is
>> +         too small.  */
>> +      if (workstart != NULL)
>> +        {
>> +          free (workstart);
>> +          workstart = NULL;
>> +        }
>
> Other places in that function use this code instead:
>
>      if (__glibc_unlikely (workstart != NULL))
>        free (workstart);
>      workstart = NULL;
>
> Is there some reason to do things differently here?

I can add the __glibc_unlikely, it's one of the few cases where it is 
unlikely to hurt.  (The branch is only taken if the memory leak is about 
to happen, so I assume it's quite rare indeed, but I don't know for sure.)

Regarding the braces, both variants already exist in this file.  I don't 
have a firm presence.  I find the one with the braces more logical.

Florian



More information about the Libc-alpha mailing list