leak-detective: remove hdr entry when reallocating zero bytes
authorMartin Willi <martin@revosec.ch>
Fri, 12 Jul 2013 17:58:02 +0000 (19:58 +0200)
committerMartin Willi <martin@revosec.ch>
Fri, 12 Jul 2013 18:00:16 +0000 (20:00 +0200)
src/libstrongswan/utils/leak_detective.c

index 674445b..ffbc620 100644 (file)
@@ -872,6 +872,12 @@ HOOK(void*, realloc, void *old, size_t bytes)
        {
                return malloc(bytes);
        }
+       /* handle zero size as a free() */
+       if (bytes == 0)
+       {
+               free(old);
+               return NULL;
+       }
 
        hdr = old - sizeof(memory_header_t);
        tail = old + hdr->bytes;