fix bugs buffer overflow