summaryrefslogtreecommitdiffstats
path: root/src/corelib/json
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/json')
-rw-r--r--src/corelib/json/qjsonparser.cpp5
-rw-r--r--src/corelib/json/qjsonparser_p.h5
2 files changed, 6 insertions, 4 deletions
diff --git a/src/corelib/json/qjsonparser.cpp b/src/corelib/json/qjsonparser.cpp
index 094cb7a76b..a9655515f4 100644
--- a/src/corelib/json/qjsonparser.cpp
+++ b/src/corelib/json/qjsonparser.cpp
@@ -497,9 +497,10 @@ namespace {
memcpy(newValues, data, size*sizeof(QJsonPrivate::Value));
data = newValues;
} else {
- data = static_cast<QJsonPrivate::Value *>(realloc(data, alloc*sizeof(QJsonPrivate::Value)));
- if (!data)
+ void *newValues = realloc(data, alloc * sizeof(QJsonPrivate::Value));
+ if (!newValues)
return false;
+ data = static_cast<QJsonPrivate::Value *>(newValues);
}
return true;
}
diff --git a/src/corelib/json/qjsonparser_p.h b/src/corelib/json/qjsonparser_p.h
index 920f265ca3..b454c655ac 100644
--- a/src/corelib/json/qjsonparser_p.h
+++ b/src/corelib/json/qjsonparser_p.h
@@ -107,11 +107,12 @@ private:
inline int reserveSpace(int space) {
if (current + space >= dataLength) {
dataLength = 2*dataLength + space;
- data = (char *)realloc(data, dataLength);
- if (!data) {
+ char *newData = (char *)realloc(data, dataLength);
+ if (!newData) {
lastError = QJsonParseError::DocumentTooLarge;
return -1;
}
+ data = newData;
}
int pos = current;
current += space;