Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.12.4, 5.13.0
-
None
-
65f9646583d74c97aab7f8ea90197e370d7bfede (qt/qtbase/5.12)
Description
QCborStreamReader(QIODevice * dev) should move the dev pos to the end of the message after it reads the message, but it doesn't.
The following code shows the problem:
QBuffer buff; buff.open(QIODevice::ReadWrite); QCborStreamWriter writer(&buff); writer.startMap(); writer.append(0); writer.append("Hi"); writer.append(1); writer.append(0xffff); writer.append(2); writer.append(1.23); writer.endMap(); auto oldPos = buff.pos(); qDebug() << buff.pos(); buff.seek(0); QCborStreamReader reader(&buff); QCborValue map = QCborValue::fromCbor(reader); if (reader.isLengthKnown()) qDebug() << "length" << reader.length(); qDebug() << oldPos << buff.pos() << (reader.lastError() == QCborError::NoError) << map[0].toString() << map[1].toInteger() << map[2].toDouble(); Q_ASSERT(oldPos == buff.pos());
The output of the previous code is:
20 length 18446744073709551615 20 5 false "Hi" 65535 1.23 ASSERT: "oldPos == buff.pos()" in file ../testStreaming/main.cpp, line 31