1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-21 11:09:43 +00:00

Merge pull request #2253 from elsid/fix_navmesh_tiles_cache_ub

Do not pass nullptr to std::memcmp
This commit is contained in:
Bret Curtis 2019-03-14 21:45:52 +01:00 committed by GitHub
commit 7bbf0b5249
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -179,6 +179,17 @@ namespace DetourNavigator
const auto lhsEnd = reinterpret_cast<const char*>(lhs.data() + lhs.size());
const auto lhsSize = static_cast<std::ptrdiff_t>(lhsEnd - lhsBegin);
const auto rhsSize = static_cast<std::ptrdiff_t>(mRhsEnd - mRhsIt);
if (lhsBegin == nullptr || mRhsIt == nullptr)
{
if (lhsSize < rhsSize)
return -1;
else if (lhsSize > rhsSize)
return 1;
else
return 0;
}
const auto size = std::min(lhsSize, rhsSize);
if (const auto result = std::memcmp(lhsBegin, mRhsIt, size))