From 2fd4a86dc5547d6ff3f512bd33ccf6e10d159ff4 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 15 Sep 2023 11:40:41 +0200 Subject: [PATCH] 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 --- src/corelib/serialization/qdatastream.h | 1 + 1 file changed, 1 insertion(+) 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);