diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index 88dd59a04d4..58fc076c216 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -1292,7 +1292,7 @@ inline qsizetype QXmlStreamReaderPrivate::fastScanContentCharList() textBuffer += QChar(ushort(c)); ++n; } - if (c == 0) { + if (c == StreamEOF) { putString(textBuffer, pos); textBuffer.resize(pos); } else if (c == '>' && textBuffer.at(textBuffer.size() - 2) == u']') { diff --git a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp index d0821781222..6f3ce0e2c02 100644 --- a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp @@ -479,14 +479,16 @@ public: ParseSinglePass }; - static bool isWellformed(QIODevice *const inputFile, const ParseMode mode) + static bool isWellformed(QFile *const inputFile, const ParseMode mode) { if (!inputFile) - qFatal("%s: inputFile must be a valid QIODevice pointer", Q_FUNC_INFO); + qFatal("%s: inputFile must be a valid QFile pointer", Q_FUNC_INFO); if (!inputFile->isOpen()) qFatal("%s: inputFile must be opened by the caller", Q_FUNC_INFO); if (mode != ParseIncrementally && mode != ParseSinglePass) qFatal("%s: mode must be either ParseIncrementally or ParseSinglePass", Q_FUNC_INFO); + if (!inputFile->seek(0)) + qFatal("%s: could not seek to the beginning of the file", Q_FUNC_INFO); if(mode == ParseIncrementally) { @@ -503,8 +505,8 @@ public: if(bufferPos < buffer.size()) { - ++bufferPos; reader.addData(QByteArray(buffer.data() + bufferPos, 1)); + ++bufferPos; } else break;