summaryrefslogtreecommitdiffstats
path: root/src/corelib/json/qjsonparser_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2016-11-02 09:37:42 +0100
committerLars Knoll <lars.knoll@qt.io>2016-11-04 07:53:39 +0000
commit15df60239d2dd3b0f0844e3ec8c91300fb7a4b67 (patch)
treee0c863154de5e1766ffb1310711d36a63b6283e6 /src/corelib/json/qjsonparser_p.h
parent4b6784b49c6dcf0add9ec0cbb4ad97cd191c2aa3 (diff)
Fix OOM crashes for huge json documents
Check all places where we reallocate our internal data structure and return a DocumentTooLarge parse error if we can't get enough memory. Change-Id: I006d0170d941837220c7dad0508571b68e2cbfd7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Kati Kankaanpaa <kati.kankaanpaa@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/corelib/json/qjsonparser_p.h')
-rw-r--r--src/corelib/json/qjsonparser_p.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/json/qjsonparser_p.h b/src/corelib/json/qjsonparser_p.h
index a395c0c92e..82a7899a51 100644
--- a/src/corelib/json/qjsonparser_p.h
+++ b/src/corelib/json/qjsonparser_p.h
@@ -102,6 +102,10 @@ private:
if (current + space >= dataLength) {
dataLength = 2*dataLength + space;
data = (char *)realloc(data, dataLength);
+ if (!data) {
+ lastError = QJsonParseError::DocumentTooLarge;
+ return -1;
+ }
}
int pos = current;
current += space;