Fixed a memory leak in an error path.