Skip to content

Commit

Permalink
fix build on travis-ci.org
Browse files Browse the repository at this point in the history
Some early returns were missing after the removal of longjmp in Tencent#22.
This has led to segfaults on Linux (confirmed locally).
  • Loading branch information
pah committed Jun 27, 2014
1 parent fbf29df commit be01d3d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/rapidjson/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,16 @@ class GenericReader {
case '[': ParseArray<parseFlags>(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();
}
Expand Down Expand Up @@ -414,13 +418,17 @@ class GenericReader {
if (parseFlags & kParseInsituFlag) {
Ch *head = s.PutBegin();
ParseStringToStream<parseFlags, SourceEncoding, SourceEncoding>(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);
}
else {
StackStream stackStream(stack_);
ParseStringToStream<parseFlags, SourceEncoding, TargetEncoding>(s, stackStream);
if (HasParseError())
return;
handler.String(stack_.template Pop<typename TargetEncoding::Ch>(stackStream.length_), stackStream.length_ - 1, true);
}
is = s; // Restore is
Expand Down

0 comments on commit be01d3d

Please sign in to comment.