Skip to content

Commit 03a7391

Browse files
authored
Merge pull request Tencent#757 from patcheng/feature/fix_clang_warning
added assertion to help suppress clang warnings
2 parents 369e07d + 95224af commit 03a7391

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

include/rapidjson/internal/stack.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class Stack {
126126

127127
template<typename T>
128128
RAPIDJSON_FORCEINLINE T* PushUnsafe(size_t count = 1) {
129+
RAPIDJSON_ASSERT(stackTop_);
129130
RAPIDJSON_ASSERT(stackTop_ + sizeof(T) * count <= stackEnd_);
130131
T* ret = reinterpret_cast<T*>(stackTop_);
131132
stackTop_ += sizeof(T) * count;

include/rapidjson/reader.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -934,11 +934,13 @@ class GenericReader {
934934
#else
935935
length = static_cast<SizeType>(__builtin_ffs(r) - 1);
936936
#endif
937-
char* q = reinterpret_cast<char*>(os.Push(length));
938-
for (size_t i = 0; i < length; i++)
939-
q[i] = p[i];
937+
if (length != 0) {
938+
char* q = reinterpret_cast<char*>(os.Push(length));
939+
for (size_t i = 0; i < length; i++)
940+
q[i] = p[i];
940941

941-
p += length;
942+
p += length;
943+
}
942944
break;
943945
}
944946
_mm_storeu_si128(reinterpret_cast<__m128i *>(os.Push(16)), s);

0 commit comments

Comments
 (0)