QmlDesigner: Avoid puppet crash

If the property is invalid the propertyTypeName is a nullptr.
Calling strcmp on nullptr is undefined and can result in a nullptr access.

Change-Id: I270091fa1d2635019ad2e41c4a5eab9985227dcf
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Thomas Hartmann
2019-02-14 17:52:28 +01:00
parent 25487daffd
commit 0f6e5a56cb

View File

@@ -267,13 +267,13 @@ static bool isList(const QQmlProperty &property)
static bool isQJSValue(const QQmlProperty &property) static bool isQJSValue(const QQmlProperty &property)
{ {
return !strcmp(property.propertyTypeName(), "QJSValue"); return property.isValid() && !strcmp(property.propertyTypeName(), "QJSValue");
} }
static bool isObject(const QQmlProperty &property) static bool isObject(const QQmlProperty &property)
{ {
/* QVariant and QJSValue can also store QObjects. Lets trust our model. */ /* QVariant and QJSValue can also store QObjects. Lets trust our model. */
return (property.propertyTypeCategory() == QQmlProperty::Object return property.isValid() && (property.propertyTypeCategory() == QQmlProperty::Object
|| !strcmp(property.propertyTypeName(), "QVariant") || !strcmp(property.propertyTypeName(), "QVariant")
|| isQJSValue(property)); || isQJSValue(property));
} }