Fix for the case when realloc returns NULL