Fix usage of realloc.