fix buffer overflow bug