diff options
Diffstat (limited to 'src/corelib/json')
-rw-r--r-- | src/corelib/json/qjsonarray.cpp | 2 | ||||
-rw-r--r-- | src/corelib/json/qjsonparser.cpp | 9 | ||||
-rw-r--r-- | src/corelib/json/qjsonvalue.cpp | 8 | ||||
-rw-r--r-- | src/corelib/json/qjsonwriter.cpp | 4 |
4 files changed, 17 insertions, 6 deletions
diff --git a/src/corelib/json/qjsonarray.cpp b/src/corelib/json/qjsonarray.cpp index d143215efd..0884f10354 100644 --- a/src/corelib/json/qjsonarray.cpp +++ b/src/corelib/json/qjsonarray.cpp @@ -87,6 +87,8 @@ QJsonArray::QJsonArray() QJsonArray::QJsonArray(QJsonPrivate::Data *data, QJsonPrivate::Array *array) : d(data), a(array) { + Q_ASSERT(data); + Q_ASSERT(array); d->ref.ref(); } diff --git a/src/corelib/json/qjsonparser.cpp b/src/corelib/json/qjsonparser.cpp index 9b11c9ac3e..a17426580f 100644 --- a/src/corelib/json/qjsonparser.cpp +++ b/src/corelib/json/qjsonparser.cpp @@ -731,7 +731,7 @@ static inline bool isUnicodeNonCharacter(uint ucs4) // U+FDEF (inclusive) return (ucs4 & 0xfffe) == 0xfffe - || (ucs4 - 0xfdd0U) < 16; + || (ucs4 - 0xfdd0U) < 32; } static inline bool scanUtf8Char(const char *&json, const char *end, uint *result) @@ -769,9 +769,10 @@ static inline bool scanUtf8Char(const char *&json, const char *end, uint *result uc = (uc << 6) | (ch & 0x3f); } - if (isUnicodeNonCharacter(uc) || uc >= 0x110000 || - (uc < min_uc) || (uc >= 0xd800 && uc <= 0xdfff)) + if (uc < min_uc || isUnicodeNonCharacter(uc) || + (uc >= 0xd800 && uc <= 0xdfff) || uc >= 0x110000) { return false; + } *result = uc; return true; @@ -850,7 +851,7 @@ bool Parser::parseString(bool *latin1) return false; } } - if (ch > 0xffff) { + if (QChar::requiresSurrogates(ch)) { int pos = reserveSpace(4); *(QJsonPrivate::qle_ushort *)(data + pos) = QChar::highSurrogate(ch); *(QJsonPrivate::qle_ushort *)(data + pos + 2) = QChar::lowSurrogate(ch); diff --git a/src/corelib/json/qjsonvalue.cpp b/src/corelib/json/qjsonvalue.cpp index a5234945a8..e25aac50f2 100644 --- a/src/corelib/json/qjsonvalue.cpp +++ b/src/corelib/json/qjsonvalue.cpp @@ -449,9 +449,17 @@ bool QJsonValue::operator==(const QJsonValue &other) const case String: return toString() == other.toString(); case Array: + if (base == other.base) + return true; + if (!base || !other.base) + return false; return QJsonArray(d, static_cast<QJsonPrivate::Array *>(base)) == QJsonArray(other.d, static_cast<QJsonPrivate::Array *>(other.base)); case Object: + if (base == other.base) + return true; + if (!base || !other.base) + return false; return QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)) == QJsonObject(other.d, static_cast<QJsonPrivate::Object *>(other.base)); } diff --git a/src/corelib/json/qjsonwriter.cpp b/src/corelib/json/qjsonwriter.cpp index d544e6154b..7cdc3f0dba 100644 --- a/src/corelib/json/qjsonwriter.cpp +++ b/src/corelib/json/qjsonwriter.cpp @@ -61,7 +61,7 @@ static inline bool isUnicodeNonCharacter(uint ucs4) // U+FDEF (inclusive) return (ucs4 & 0xfffe) == 0xfffe - || (ucs4 - 0xfdd0U) < 16; + || (ucs4 - 0xfdd0U) < 32; } static inline uchar hexdig(uint u) @@ -160,7 +160,7 @@ static QByteArray escapedString(const QString &s) continue; } - if (u > 0xffff) { + if (QChar::requiresSurrogates(u)) { *cursor++ = 0xf0 | ((uchar) (u >> 18)); *cursor++ = 0x80 | (((uchar) (u >> 12)) & 0x3f); } else { |