diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2023-09-15 11:40:41 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2023-09-17 18:33:47 +0000 |
commit | 2fd4a86dc5547d6ff3f512bd33ccf6e10d159ff4 (patch) | |
tree | 22b71fcb147f64a255ffbe94c8192d48e2f1d52b /src/corelib/serialization | |
parent | b0ba5c78eee0a476f5ab3e55e3bf3b5476e481c4 (diff) |
QDataStream: prevent accidental streaming of pointers
It doesn't make sense to stream a pointer, but it can happen by
accident because ds << ptr will select the operator<<(bool) overload.
Disable the out-stream operator for pointers by having a better match.
Reading a pointer from a QDataStream doesn't work, as a pointer
can't bind to e.g. a bool non-const reference.
[ChangeLog][QtCore][QDataStream] Streaming of arbitrary pointers
using QDataStream has been disabled. Note that such streaming happened
through the streaming operator for bool.
Change-Id: I4c98a33b52aae85e441f5a096efd404fbbf1e95f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization')
-rw-r--r-- | src/corelib/serialization/qdatastream.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/serialization/qdatastream.h b/src/corelib/serialization/qdatastream.h index 69a7765064..e5ae55402a 100644 --- a/src/corelib/serialization/qdatastream.h +++ b/src/corelib/serialization/qdatastream.h @@ -157,6 +157,7 @@ public: QDataStream &operator<<(const char *str); QDataStream &operator<<(char16_t c); QDataStream &operator<<(char32_t c); + QDataStream &operator<<(const volatile void *) = delete; QDataStream &readBytes(char *&, uint &len); |