From: Tasuku Suzuki Date: Tue, 7 Jul 2015 14:08:30 +0000 (+0900) Subject: add null check for qmlRegisterSingletonType() X-Git-Tag: v5.5.90+alpha1~3^2~28 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=38a9e94e0ee5ca8bf163fd3ed8d5d6e7fda31252;p=platform%2Fupstream%2Fqtdeclarative.git add null check for qmlRegisterSingletonType() When the callback passed to the function returns nullptr, QQmlData::ensurePropertyCache(e, o) crashes. Change-Id: I11efd7e9d6c5f18611e796d896384dd14a280303 Reviewed-by: Michael Brasser Reviewed-by: Christopher Adams Reviewed-by: Simon Hausmann --- diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 41d44a8..cb8c2bd 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -225,6 +225,9 @@ void QQmlType::SingletonInstanceInfo::init(QQmlEngine *e) v4->pushGlobalContext(); QObject *o = qobjectCallback(e, e); setQObjectApi(e, o); + if (!o) { + qFatal("qmlRegisterSingletonType(): \"%s\" is not available because the callback function returns a null pointer.", qPrintable(typeName)); + } // if this object can use a property cache, create it now QQmlData::ensurePropertyCache(e, o); v4->popContext();