Winnerhust/inifile2

注释中有中文字符会崩溃

Opened this issue · 0 comments

visual C++ 2017
编译配置 debug , ‘使用多字节字符集’

在函数 IniFile::trim 中,调用的 c 函数 isspace 中传入中文字符就会崩溃

经查,isspace 参数是 int ,传入 中文字符可能是 负数的 char, 而 isspace 内部某个位置 又强转成无符号 int ,从而导致 结果是个超过 256 的 int ;但 某处 又断言 要小于等于 256

临时解决方法:强转成 unsigned char :
isspace((unsigned char)str[i])