Skip to content

Commit

Permalink
Merge pull request Tencent#727 from mapbox/silence-dereference-null-p…
Browse files Browse the repository at this point in the history
…ointer

Silence false positive clang-tidy warning
  • Loading branch information
miloyip authored Mar 6, 2019
2 parents 7484e06 + 16872af commit 3cf4f7c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions include/rapidjson/internal/stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "../allocators.h"
#include "swap.h"
#include <cstddef>

#if defined(__clang__)
RAPIDJSON_DIAG_PUSH
Expand Down Expand Up @@ -114,7 +115,7 @@ class Stack {
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);
}

Expand All @@ -127,7 +128,7 @@ class Stack {
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;
Expand Down

0 comments on commit 3cf4f7c

Please sign in to comment.