Uninitialized memory in unit test
Unit test EsmFixedString::operator__eq_ne tries to access uninitialized memory.
Unit test code (test_fixed_string.cpp): ESM::NAME name; name.assign("asdc"); char s[4] = {'a', 's', 'd', 'c'};
Implementation (esmcommon.hpp): bool operator==(const char* const str) const { char const* const data = self()->ro_data(); for(size_t i = 0; i < size; ++i) { if(data[i] != str[i]) return false; else if(data[i] == '\0') return true; } return str[size] == '\0'; }
The line "return str[size] == '\0';" will try to access 5th element of s[4]. It seems that in Release builds on Linux it works fine, because there is usually 0 in uninitialized memory. Visual Studio puts 0xCD into all uninitialized memory locations, and test fails.
Either: A) unit test is wrong, and we shouldn't compare ESM:NAME to not null-terminated strings. B) implementation is wrong, and it shouldn't check NULL at the end of str. I'm not sure which is true, so I'm submitting an issue instead of the fix.
The code is quite old, so it is not recent regression.
@kpp Could You help with this issue ?