diff options
author | Milo Yip <miloyip@gmail.com> | 2019-03-06 09:33:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-06 09:33:13 +0800 |
commit | 3cf4f7c5a030e9a65b842d2e160ffee90df7613d (patch) | |
tree | 10ee0a9628e060536894b25cea50659a2a93a075 | |
parent | 7484e06c589873e1ed80382d262087e4fa80fb63 (diff) | |
parent | 16872af88915176f49e389defb167f899e2c230a (diff) | |
download | rapidjson-3cf4f7c5a030e9a65b842d2e160ffee90df7613d.tar.gz |
Merge pull request #727 from mapbox/silence-dereference-null-pointer
Silence false positive clang-tidy warning
-rw-r--r-- | include/rapidjson/internal/stack.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/include/rapidjson/internal/stack.h b/include/rapidjson/internal/stack.h index 89558d0..45dca6a 100644 --- a/include/rapidjson/internal/stack.h +++ b/include/rapidjson/internal/stack.h @@ -17,6 +17,7 @@ #include "../allocators.h" #include "swap.h" +#include <cstddef> #if defined(__clang__) RAPIDJSON_DIAG_PUSH @@ -114,7 +115,7 @@ public: template<typename T> RAPIDJSON_FORCEINLINE void Reserve(size_t count = 1) { // Expand the stack if needed - if (RAPIDJSON_UNLIKELY(stackTop_ + sizeof(T) * count > stackEnd_)) + if (RAPIDJSON_UNLIKELY(static_cast<std::ptrdiff_t>(sizeof(T) * count) > (stackEnd_ - stackTop_))) Expand<T>(count); } @@ -127,7 +128,7 @@ public: template<typename T> RAPIDJSON_FORCEINLINE T* PushUnsafe(size_t count = 1) { RAPIDJSON_ASSERT(stackTop_); - RAPIDJSON_ASSERT(stackTop_ + sizeof(T) * count <= stackEnd_); + RAPIDJSON_ASSERT(static_cast<std::ptrdiff_t>(sizeof(T) * count) <= (stackEnd_ - stackTop_)); T* ret = reinterpret_cast<T*>(stackTop_); stackTop_ += sizeof(T) * count; return ret; |