summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetatype.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-09-09 10:37:19 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-09-11 06:23:15 +0200
commitf9f1043e8a7706cbf6011ff4a42922b976b7a7fd (patch)
tree8cfa566285a8282cc2a25ff5d2f27a042203dca8 /src/corelib/kernel/qmetatype.cpp
parent3a1dad83ed97583551fa2fd8bf73986cd941f063 (diff)
QVariant: guard usage of fromType.metaObject()
This patch amends 19874d6a63. That patch caused a crash to occur when running the auto test tst_QQuickApplicationWindow::attachedProperties(). The crash can be traced back to QMetaType trying to access fromType.metaObject(), which is null. This patch will add a guard to ensure that we don't try to call a function on an object that is null. Fixes: QTBUG-86517 Change-Id: Idafd154a7b6a43e16126038fc5f9b30d7871f0d0 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/kernel/qmetatype.cpp')
-rw-r--r--src/corelib/kernel/qmetatype.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 553929955d..7b78b96d09 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -2049,7 +2049,7 @@ bool QMetaType::convert(QMetaType fromType, const void *from, QMetaType toType,
if (fromObject && fromObject->metaObject()->inherits(toType.metaObject())) {
*static_cast<QObject **>(to) = toType.metaObject()->cast(fromObject);
return true;
- } else if (!fromObject) {
+ } else if (!fromObject && fromType.metaObject()) {
// if fromObject is null, use static fromType to check if conversion works
*static_cast<void **>(to) = nullptr;
return fromType.metaObject()->inherits(toType.metaObject());