From 95224aff7dff65c448dca374b4c7fccc32680e5c Mon Sep 17 00:00:00 2001 From: Patrick Cheng Date: Fri, 30 Sep 2016 13:44:15 -0700 Subject: [PATCH] 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. --- include/rapidjson/reader.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h index 19f8849..e3523a0 100644 --- a/include/rapidjson/reader.h +++ b/include/rapidjson/reader.h @@ -948,11 +948,13 @@ private: #else length = static_cast(__builtin_ffs(r) - 1); #endif - char* q = reinterpret_cast(os.Push(length)); - for (size_t i = 0; i < length; i++) - q[i] = p[i]; + if (length != 0) { + char* q = reinterpret_cast(os.Push(length)); + for (size_t i = 0; i < length; i++) + q[i] = p[i]; - p += length; + p += length; + } break; } _mm_storeu_si128(reinterpret_cast<__m128i *>(os.Push(16)), s);