diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp index a61c867ff6..d233c1b01e 100644 --- a/src/corelib/serialization/qcborvalue.cpp +++ b/src/corelib/serialization/qcborvalue.cpp @@ -1508,14 +1508,18 @@ static inline QCborContainerPrivate *createContainerFromCbor(QCborStreamReader & } reader.enterContainer(); - if (reader.lastError() != QCborError::NoError) + if (reader.lastError() != QCborError::NoError) { + d->elements.clear(); return d; + } while (reader.hasNext() && reader.lastError() == QCborError::NoError) d->decodeValueFromCbor(reader, remainingRecursionDepth - 1); if (reader.lastError() == QCborError::NoError) reader.leaveContainer(); + else + d->elements.squeeze(); return d; }