summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qdatastream.cpp
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2024-01-24 17:30:58 +0100
committerIvan Solovev <ivan.solovev@qt.io>2024-02-07 15:02:19 +0100
commitdd514160ce169734e23a146a2c115fed55a69260 (patch)
tree1a642ce568efed839a24154478a11fbd546bd651 /src/corelib/serialization/qdatastream.cpp
parent0ed34d19926c60f3b74a58723c5c36f366e99d95 (diff)
QDataStream: use SizeLimitExceeded status in write operations
Set this status when the stream tries to write more data than the current serialization format supports. Update the methods that write containers to return early if they fail to write the container size, and do not try to serialize the elements. Convert the manual tst_manualqdatastream test into a data-driven test, allowing us to specify various stream versions. Adjust the test code to check that the SizeLimitExceeded status is set when the stream version is <= Qt_6_6. Amends fd48ce0b73c74dafd5db27bc1f2752ef665df7ef Found in 6.7 API review Pick-to: 6.7 Change-Id: If4c62ea53ac9bccd423f00f0f03afd6ba6bdc4f5 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization/qdatastream.cpp')
-rw-r--r--src/corelib/serialization/qdatastream.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/serialization/qdatastream.cpp b/src/corelib/serialization/qdatastream.cpp
index 7c4c5cc12af..d0421f70fad 100644
--- a/src/corelib/serialization/qdatastream.cpp
+++ b/src/corelib/serialization/qdatastream.cpp
@@ -1397,8 +1397,8 @@ QDataStream &QDataStream::writeBytes(const char *s, qint64 len)
return *this;
}
CHECK_STREAM_WRITE_PRECOND(*this)
- writeQSizeType(*this, len); // write length specifier
- if (len > 0)
+ // Write length then, if any, content
+ if (writeQSizeType(*this, len) && len > 0)
writeRawData(s, len);
return *this;
}