Removed memory leak in error case.