Fix some realloc error handling issues.