fix pointer handling after realloc