From dd0b45ede66934d904831ee7e979349497b5d5a3 Mon Sep 17 00:00:00 2001 From: elsid Date: Thu, 14 Mar 2019 22:15:57 +0300 Subject: [PATCH] Do not pass nullptr to std::memcmp --- components/detournavigator/navmeshtilescache.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/detournavigator/navmeshtilescache.cpp b/components/detournavigator/navmeshtilescache.cpp index 76060981f4..8dd14f04c3 100644 --- a/components/detournavigator/navmeshtilescache.cpp +++ b/components/detournavigator/navmeshtilescache.cpp @@ -179,6 +179,17 @@ namespace DetourNavigator const auto lhsEnd = reinterpret_cast(lhs.data() + lhs.size()); const auto lhsSize = static_cast(lhsEnd - lhsBegin); const auto rhsSize = static_cast(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))