fix buffer overflow and underflow