fix buffer overflow in main.cpp