Fixed parsing when opening brace/bracket is missing

This commit is contained in:
Benoit Blanchon committed 2014-10-31 16:50:21 +01:00
1 parent 2b5b8fb4c5
commit 74b4544560
3 files changed
+13 -7

No files matched your search

+3 -3
View File
@@ -74,9 +74,9 @@ void JsonParser::parseAnythingTo(JsonValue &destination) {
}
JsonArray &JsonParser::parseArray() {
skip('[');
if (!skip('[')) return JsonArray::invalid(); // missing opening bracket
if (isEnd()) return JsonArray::invalid();
if (isEnd()) return JsonArray::invalid(); // end of stream
JsonArray &array = _buffer->createArray();
if (skip(']')) return array; // empty array
@@ -127,7 +127,7 @@ void JsonParser::parseNullTo(JsonValue &destination) {
}
JsonObject &JsonParser::parseObject() {
skip('{');
if (!skip('{')) return JsonObject::invalid(); // missing opening brace
if (isEnd()) return JsonObject::invalid(); // premature ending