Assetion in `std::string buffer::get_line(bool skip_whitespace)`, with MSVC build
Try opened this issue · comments
Try commented
Offended code:
std::string buffer::get_line(bool skip_whitespace) {
...
if (skip_whitespace) {
auto count = mismatch([](char chr) { return !std::isspace(chr); }); // <--
if (count == -1) {
position(limit()); // the end of the buffer has been reached
} else {
position(position() + count);
}
}
return tmp;
}
char
can be signed on some C++ implementations, and have negative values.
Issue was hit, when parsing world mesh in steam-eng version of gothic2
Luis Michaelis commented
Hm interesting. To my knowledge isspace
is supposed to take an int
anyways (see cppreference)? Regardless I'll see if I can reproduce on MinGW on Linux so that I can actually see what's going on here :)
Update: I missed the most crucial part
The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.
I will implement a fix later.
Luis Michaelis commented
Fixed in 69cd380.