zrealloc is supposed to handle freeing the old pointer when called, but
when called with size 0, it was not always working as expected. This
commit fixes the bug. Thanks to Agostino Sarubbo of Gentoo for providing
a bug report with a reproducible test case.
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
}
void *zrealloc(void *ptr, size_t size) {
+ /* Handle requested size of zero */
+ if(size == 0) {
+ if(ptr != NULL)
+ free(ptr);
+ return NULL;
+ }
+
void *ret = realloc(ptr, size);
/*
* Realloc does not touch the original block if fails.