fixed a potential buffer overflow bug on the stack (thanks to Ghassan Misherg)