Blob Blame History Raw
From b25f776b1761fb4b3bfbcb040da726ea5599fa56 Mon Sep 17 00:00:00 2001
From: Robin Lee <cheeselee@fedoraproject.org>
Date: Tue, 3 Nov 2020 16:34:36 +0800
Subject: [PATCH] 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 RHBZ#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 d66be11..06a0550 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