Repair buffer overflow - BUG

Special thanks for @msharov!