summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-01-23 14:20:02 -0800
committerThiago Macieira <thiago.macieira@intel.com>2015-02-15 01:22:59 +0000
commit0fa7374f1dc433b6b8955cb14dabb22c10f50854 (patch)
treef4b5f2f232fa1f0b31d296edae6f77309c7d438c /src/corelib
parent2be0d3088fc5bc52ece6b28157b28d16699ccb9b (diff)
Ensure that the binary JSON objects are actually sorted
QJsonObject requires that, since it does binary searches for the keys. Change-Id: I8a7a116f51864cecb52fffff13bc24660c1cc1ac Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/json/qjson.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/corelib/json/qjson.cpp b/src/corelib/json/qjson.cpp
index 8fa172eae8..abba1f1b49 100644
--- a/src/corelib/json/qjson.cpp
+++ b/src/corelib/json/qjson.cpp
@@ -200,6 +200,7 @@ bool Object::isValid() const
if (tableOffset + length*sizeof(offset) > size)
return false;
+ QString lastKey;
for (uint i = 0; i < length; ++i) {
offset entryOffset = table()[i];
if (entryOffset + sizeof(Entry) >= tableOffset)
@@ -208,8 +209,12 @@ bool Object::isValid() const
int s = e->size();
if (table()[i] + s > tableOffset)
return false;
+ QString key = e->key();
+ if (key < lastKey)
+ return false;
if (!e->value.isValid(this))
return false;
+ lastKey = key;
}
return true;
}