GothicKit / ZenKit

A re-implementation of file formats used by the early 2000's ZenGin

Home Page:http://zk.gothickit.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assetion in `std::string buffer::get_line(bool skip_whitespace)`, with MSVC build

Try opened this issue · comments

commented

изображение
sorry for awful screenshot :)

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

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.