Fix possible buffer overflow