Make sure string buffer is correctly terminated