Don't assume realloc() can handle NULL pointers (backport from trunk)