diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2011-11-29 12:53:06 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@nokia.com> | 2011-12-02 11:00:57 +0100 |
commit | d8add9504926add171f76f97ea65b49d13b6d823 (patch) | |
tree | 92aac81214d15da0cc80376ee48907946e1f876f | |
parent | 09bb332f09c8975dad4f448cc786cfb022111e00 (diff) | |
download | qt-creator-d8add9504926add171f76f97ea65b49d13b6d823.tar.gz |
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 <leandro.melo@nokia.com>
(cherry picked from commit 9b411ed5588db9dcbea955e4e45f99b5d06c1cbe)
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
-rw-r--r-- | src/plugins/qmljseditor/qmljsfindreferences.cpp | 9 |
1 files 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); } |