From 4ce000b9f59753105c3ede25d656b8e4dab3145c Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Fri, 29 Jan 2016 10:53:33 +0800 Subject: [PATCH] Fix out-of-bound access --- include/rapidjson/internal/regex.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/rapidjson/internal/regex.h b/include/rapidjson/internal/regex.h index 8da60f6..2e5ca58 100644 --- a/include/rapidjson/internal/regex.h +++ b/include/rapidjson/internal/regex.h @@ -143,7 +143,12 @@ private: public: DecodedStream(SourceStream& ss) : ss_(ss), codepoint_() { Decode(); } unsigned Peek() { return codepoint_; } - unsigned Take() { unsigned c = codepoint_; Decode(); return c; } + unsigned Take() { + unsigned c = codepoint_; + if (c) // No further decoding when '\0' + Decode(); + return c; + } private: void Decode() {