proper realloc failure check