Fix a memory leak in the error path.