fix buffer overflow bug

@lxyu