fix a critical bug (buffer overflow)