diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2019-07-17 09:41:31 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2019-07-19 12:31:42 -0700 |
commit | 65f9646583d74c97aab7f8ea90197e370d7bfede (patch) | |
tree | ac39b47a58e00b5392284928f58b309dc49d8347 /src/corelib/serialization/qcborstream.cpp | |
parent | 89e0c2854a9dc098380e5286b26de187d04f9826 (diff) |
Fix QCborStreamReader not flushing QIODevices due to internal buffering
When successfully finishing a parse, it's reasonable to expect that the
QIODevice was advanced to the end of the input data.
[ChangeLog][QtCore][QCborStreamReader] Fixed a bug that caused the
QIODevice that the data was being read from not to show the entire CBOR
message as consumed. This allows the user to consume data that may
follow the CBOR payload.
Fixes: QTBUG-77076
Change-Id: I1024ee42da0c4323953afffd15b23f5d8fcc6f50
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Diffstat (limited to 'src/corelib/serialization/qcborstream.cpp')
-rw-r--r-- | src/corelib/serialization/qcborstream.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/corelib/serialization/qcborstream.cpp b/src/corelib/serialization/qcborstream.cpp index 87ae316041..dc00118cfd 100644 --- a/src/corelib/serialization/qcborstream.cpp +++ b/src/corelib/serialization/qcborstream.cpp @@ -1956,7 +1956,15 @@ inline void QCborStreamReader::preparse() if (lastError() == QCborError::NoError) { type_ = cbor_value_get_type(&d->currentElement); - if (type_ != CborInvalidType) { + if (type_ == CborInvalidType) { + // We may have reached the end. + if (d->device && d->containerStack.isEmpty()) { + d->buffer.clear(); + if (d->bufferStart) + d->device->skip(d->bufferStart); + d->bufferStart = 0; + } + } else { d->lastError = {}; // Undo the type mapping that TinyCBOR does (we have an explicit type // for negative integer and we don't have separate types for Boolean, |