This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]