diff options
Diffstat (limited to 'source3/lib/talloc.c')
-rw-r--r-- | source3/lib/talloc.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/source3/lib/talloc.c b/source3/lib/talloc.c index e83369f379e..a8ee481744b 100644 --- a/source3/lib/talloc.c +++ b/source3/lib/talloc.c @@ -80,6 +80,14 @@ void *talloc_realloc(TALLOC_CTX *t, void *ptr, size_t size) { struct talloc_chunk *tc; + /* size zero is equivalent to free() */ + if (size == 0) + return NULL; + + /* realloc(NULL) is equavalent to malloc() */ + if (ptr == NULL) + return talloc(t, size); + for (tc=t->list; tc; tc=tc->next) { if (tc->ptr == ptr) { ptr = realloc(ptr, size); |