Memory leak in ev.c

Kevyn-Alexandre Paré kapare at rogue-research.com
Wed Feb 20 18:24:35 CET 2013


Hi,

This is not causing a memory leak.

The man page of realloc says that:

if size is equal to zero, and  ptr  is not NULL, then the call is equivalent to free(ptr).

My only concern about this way of freeing is about that post:

https://www.securecoding.cert.org/confluence/display/seccode/MEM04-C.+Do+not+perform+zero-length+allocations

?

Best Regards,

- KA

On 2013-02-20, at 10:50 AM, Alexander Klauer wrote:

> Hi,
> 
> On 02/20/2013 04:42 PM, Alexander Klauer wrote:
>> 
>> in ev.c, there is the definition
>> 
>> #define ev_free(ptr)    ev_realloc ((ptr), 0)
>> 
>> This causes a memory leak on systems where zero-sized objects are being kept track of. Therefore, I suggest this definition to be changed to
>> 
>> #define ev_free(ptr)    free ((ptr))
>> 
> 
> alternatively, one might also change ev_realloc_emul() in the same file to keep only the #else part of the #ifdef __GLIBC__. This might be the better solution if there are non-standard systems out there which do not properly implement free(0).
> 
> Best regards,
> Alexander
> 
> _______________________________________________
> libev mailing list
> libev at lists.schmorp.de
> http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev




More information about the libev mailing list