Fix potential buffer overflow.