From cf51cdb8fb002ae3602a4c886e7c67913d77373a Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Tue, 3 Dec 2013 21:47:02 +0100 Subject: QQmlImport: Don't try use a dangling pointer. toUtf8 would return a temporary, and constData would hold a pointer inside that temporary. This isn't even remotely safe. Move the pointer use down to the initializeEngine call so it is kept around long enough for us to do our stuff. Task-number: QTBUG-35355 Task-number: QTBUG-35343 Change-Id: Ie816d0d1a37e42607f26d9ad02cf999f3d459cd9 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlimport.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/qml/qml/qqmlimport.cpp') diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 30b5abb383..8645d2116a 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -1966,8 +1966,7 @@ bool QQmlImportDatabase::importPlugin(const QString &filePath, const QString &ur if (QQmlExtensionInterface *eiface = qobject_cast(instance)) { QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); - const char *moduleId = uri.toUtf8().constData(); - ep->typeLoader.initializeEngine(eiface, moduleId); + ep->typeLoader.initializeEngine(eiface, uri.toUtf8().constData()); } } } -- cgit v1.2.3