On 05/03/2016 07:05 PM, Donald Sharp wrote:
> If you pass in a NULL ptr, but with a size, it acts as a malloc.  From
> the man page:
> 
>  If ptr is NULL, then the call is equivalent to
>        malloc(size), for all values of size; if size is equal to zero,
> and ptr is not NULL, then the call is equivalent to
>        free(ptr).
> 
> Not a good patch imo.

The whole zrealloc function with the patch looks like this (let's hope
Thunderbird doesn't screw it up too badly):

 void *
 zrealloc (int type, void *ptr, size_t size)
 {
   void *memory;

   if (ptr == NULL)              /* is really alloc */
       return zcalloc(type, size);

   memory = realloc (ptr, size);
   if (memory == NULL)
     zerror ("realloc", type, size);

-  if (ptr == NULL)
-    alloc_inc (type);

   return memory;
 }

So if NULL is passed in as ptr to zrealloc, it will return the result of
zcalloc. The code that I remove in the patch will never be called.

-Christian

_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to