From 9cc1825c0ba16c94cf1d74741ca0941e6586ab1a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 1 Jul 2024 09:31:29 +0200 Subject: [PATCH] QDBusSignature: fix default ctor to not allocate memory The QDBusSignature default ctor is noexcept since 49f7281d36028055e61175c23bc455b4147480b9 (Qt 5.5-ish), so detach() (which must needs allocate memory) cannot be used without breaking the contract. Fix by assigning ""_L1 instead, the canonical way to access the shared empty state. While fromLatin1() isn't noexcept, fromLatin1(""_L1) never throws. Amends ed6d1fa71a79a70b7e6a20fbbc737ed9f6c287b1. Pick-to: 6.7 6.5 Task-number: QTBUG-124919 Change-Id: I5f0c3bdc199998deaa22971a60388f8f3ed0eaa8 Reviewed-by: Thiago Macieira (cherry picked from commit 11dbf821942dbda6e53d7bfcf378904318634196) Reviewed-by: Qt Cherry-pick Bot --- src/dbus/qdbusextratypes.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/dbus/qdbusextratypes.h b/src/dbus/qdbusextratypes.h index c548cbe7bb5..cb63df4f932 100644 --- a/src/dbus/qdbusextratypes.h +++ b/src/dbus/qdbusextratypes.h @@ -78,9 +78,8 @@ class Q_DBUS_EXPORT QDBusSignature QString m_signature; public: QDBusSignature() noexcept - { - m_signature.detach(); // mark non-null (empty signatures are valid) - } + : m_signature(QLatin1StringView("")) // mark non-null (empty signatures are valid) + {} // compiler-generated copy/move constructor/assignment operators are ok! // compiler-generated destructor is ok!