Skip to content

Commit 95224af

Browse files
committed
When length is 0, the code does nothing, so skip it completely.
Previously, os.Push(0) would do nothing as well. But with the newly added assertion, is the stack is empty, it will fail the assertion.
1 parent 91a803d commit 95224af

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

include/rapidjson/reader.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -948,11 +948,13 @@ class GenericReader {
948948
#else
949949
length = static_cast<SizeType>(__builtin_ffs(r) - 1);
950950
#endif
951-
char* q = reinterpret_cast<char*>(os.Push(length));
952-
for (size_t i = 0; i < length; i++)
953-
q[i] = p[i];
951+
if (length != 0) {
952+
char* q = reinterpret_cast<char*>(os.Push(length));
953+
for (size_t i = 0; i < length; i++)
954+
q[i] = p[i];
954955

955-
p += length;
956+
p += length;
957+
}
956958
break;
957959
}
958960
_mm_storeu_si128(reinterpret_cast<__m128i *>(os.Push(16)), s);

0 commit comments

Comments
 (0)