Fix possible memory leak in error path
Possible leak in main()