Fix the handling of realloc failures.
Assigning the result of realloc directly to the varaiable being resized
can cause a memory leak, because the result of realloc can be NULL. Our
code probably still can't deal with malloc failures, and I'm not sure if
malloc/realloc can ever return NULL at all these days, but this fix will
keep us from being haunted by the ghosts of all of our intro to CS
instructors.