mirror of
https://github.com/Tencent/rapidjson.git
synced 2025-03-09 03:03:38 +01:00
Merge pull request #26 from pah/fixes/errorreturn-castqual
Fix segfault and build error on Linux
This commit is contained in:
commit
b2b12a6367
@ -202,7 +202,7 @@ public:
|
||||
*/
|
||||
template <typename SourceAllocator>
|
||||
GenericValue& CopyFrom(const GenericValue<Encoding,SourceAllocator>& 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;
|
||||
|
@ -243,12 +243,16 @@ public:
|
||||
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();
|
||||
}
|
||||
@ -414,6 +418,8 @@ private:
|
||||
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);
|
||||
@ -421,6 +427,8 @@ private:
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user