Unverified Commit 5c47e2e9 authored by Salvatore Sanfilippo's avatar Salvatore Sanfilippo Committed by GitHub
Browse files

Merge pull request #4696 from oranagra/zrealloc_fix

Fix zrealloc to behave similarly to je_realloc when size is 0
parents 5c21eca6 5def6500
...@@ -148,6 +148,10 @@ void *zrealloc(void *ptr, size_t size) { ...@@ -148,6 +148,10 @@ void *zrealloc(void *ptr, size_t size) {
size_t oldsize; size_t oldsize;
void *newptr; void *newptr;
if (size == 0 && ptr!=NULL) {
zfree(ptr);
return NULL;
}
if (ptr == NULL) return zmalloc(size); if (ptr == NULL) return zmalloc(size);
#ifdef HAVE_MALLOC_SIZE #ifdef HAVE_MALLOC_SIZE
oldsize = zmalloc_size(ptr); oldsize = zmalloc_size(ptr);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment