Bugfix: realloc() with size == 0 works like free() and returns NULL, so don’t die()

This commit is contained in:
Michael Stapelberg 2011-08-03 20:43:08 +02:00
parent 192dbdabd6
commit e616b45c83
1 changed files with 2 additions and 1 deletions

View File

@ -77,7 +77,8 @@ void *scalloc(size_t size) {
void *srealloc(void *ptr, size_t size) {
void *result = realloc(ptr, size);
exit_if_null(result, "Error: out memory (realloc(%zd))\n", size);
if (result == NULL && size > 0)
die("Error: out memory (realloc(%zd))\n", size);
return result;
}