fix possible buffer overflow