Fix memory leak if krealloc() fails