Fix buffer overrun when handling strings