Blob Blame History Raw
From 6e425c72be1c73c4b3139b749d1f5d0cabe9de6a Mon Sep 17 00:00:00 2001
From: Robin Lee <cheeselee@fedoraproject.org>
Date: Tue, 3 Nov 2020 16:34:36 +0800
Subject: [PATCH 1/2] fix: QVariant should be created with
 QMetaProperty::userType()

QMetaProperty::type() always returns QVariant::UserType for any user-defined
type. So QVariant of type id 1024(QVariant::UserType) is always created instead
of the right type whose type ID is returned from QMetaProperty::userType().
Creating QVariant with wrong type may crash the process.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1892710

Log: QVariant should be created with QMetaProperty::userType()
Signed-off-by: Robin Lee <cheeselee@fedoraproject.org>
---
 .../qtdbusextended/dbusextendedabstractinterface.cpp          | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libdframeworkdbus/qtdbusextended/dbusextendedabstractinterface.cpp b/libdframeworkdbus/qtdbusextended/dbusextendedabstractinterface.cpp
index b00ec1a..54d46f3 100644
--- a/libdframeworkdbus/qtdbusextended/dbusextendedabstractinterface.cpp
+++ b/libdframeworkdbus/qtdbusextended/dbusextendedabstractinterface.cpp
@@ -177,7 +177,7 @@ QVariant DBusExtendedAbstractInterface::internalPropGet(const char *propname, vo
     if (m_useCache) {
         int propertyIndex = metaObject()->indexOfProperty(propname);
         QMetaProperty metaProperty = metaObject()->property(propertyIndex);
-        return QVariant(metaProperty.type(), propertyPtr);
+        return QVariant(metaProperty.userType(), propertyPtr);
     }
 
     if (m_sync) {
@@ -233,7 +233,7 @@ QVariant DBusExtendedAbstractInterface::internalPropGet(const char *propname, vo
         }
 
         asyncProperty(propname);
-        return QVariant(metaProperty.type(), propertyPtr);
+        return QVariant(metaProperty.userType(), propertyPtr);
     }
 }
 
-- 
2.26.2