From be01d3d7cca6a0c3614778ff87e5eca4ab8fe89e Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Fri, 27 Jun 2014 10:26:37 +0200 Subject: [PATCH 1/2] fix build on travis-ci.org Some early returns were missing after the removal of longjmp in #22. This has led to segfaults on Linux (confirmed locally). --- include/rapidjson/reader.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h index 4a184c0..8b58c5a 100644 --- a/include/rapidjson/reader.h +++ b/include/rapidjson/reader.h @@ -243,12 +243,16 @@ public: case '[': ParseArray(is, handler); break; default: RAPIDJSON_PARSE_ERROR_NORETURN("Expect either an object or array at root", is.Tell()); } + if (HasParseError()) + goto out; + SkipWhitespace(is); if (is.Peek() != '\0') RAPIDJSON_PARSE_ERROR_NORETURN("Nothing should follow the root object or array.", is.Tell()); } + out: stack_.Clear(); return !HasParseError(); } @@ -414,6 +418,8 @@ private: if (parseFlags & kParseInsituFlag) { Ch *head = s.PutBegin(); ParseStringToStream(s, s); + if (HasParseError()) + return; size_t length = s.PutEnd(head) - 1; RAPIDJSON_ASSERT(length <= 0xFFFFFFFF); handler.String((typename TargetEncoding::Ch*)head, SizeType(length), false); @@ -421,6 +427,8 @@ private: else { StackStream stackStream(stack_); ParseStringToStream(s, stackStream); + if (HasParseError()) + return; handler.String(stack_.template Pop(stackStream.length_), stackStream.length_ - 1, true); } is = s; // Restore is From 0277ebdc3ca39b40e76fb1b9e6ad3b554a192a73 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Fri, 27 Jun 2014 10:27:35 +0200 Subject: [PATCH 2/2] document.h: avoid casting away const Another instance of casting away constness via C-style cast has been missed (introduced by #20). --- include/rapidjson/document.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 40a0442..3f21062 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -202,7 +202,7 @@ public: */ template GenericValue& CopyFrom(const GenericValue& rhs, Allocator& allocator) { - RAPIDJSON_ASSERT((void*)this != (void*)&rhs); + RAPIDJSON_ASSERT((void*)this != (void const*)&rhs); this->~GenericValue(); new (this) GenericValue(rhs,allocator); return *this;