From d8add9504926add171f76f97ea65b49d13b6d823 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Tue, 29 Nov 2011 12:53:06 +0100 Subject: QmlJS: Fix potential crash in find usages. When invalid documents or documents without idEnvironment or rootScope get added to a QmlComponentChain. Change-Id: I64b7062881f19777ba20efda6efa2e7bab02571e Reviewed-by: Leandro Melo (cherry picked from commit 9b411ed5588db9dcbea955e4e45f99b5d06c1cbe) Reviewed-by: Eike Ziller --- src/plugins/qmljseditor/qmljsfindreferences.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmljseditor/qmljsfindreferences.cpp b/src/plugins/qmljseditor/qmljsfindreferences.cpp index 49b18e499d..1dddc575de 100644 --- a/src/plugins/qmljseditor/qmljsfindreferences.cpp +++ b/src/plugins/qmljseditor/qmljsfindreferences.cpp @@ -246,13 +246,14 @@ protected: private: bool contains(const QmlComponentChain *chain) { - if (!chain || !chain->document()) + if (!chain || !chain->document() || !chain->document()->bind()) return false; - if (chain->document()->bind()->idEnvironment()->lookupMember(_name, _scopeChain.context())) - return chain->document()->bind()->idEnvironment() == _scope; + const ObjectValue *idEnv = chain->document()->bind()->idEnvironment(); + if (idEnv && idEnv->lookupMember(_name, _scopeChain.context())) + return idEnv == _scope; const ObjectValue *root = chain->document()->bind()->rootObjectValue(); - if (root->lookupMember(_name, _scopeChain.context())) { + if (root && root->lookupMember(_name, _scopeChain.context())) { return check(root); } -- cgit v1.2.1