fix memory leak in main.cpp