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>
This commit is contained in:
Christian Kamm
2011-11-29 12:53:06 +01:00
parent e277ace619
commit 9b411ed558

View File

@@ -246,13 +246,14 @@ protected:
private: private:
bool contains(const QmlComponentChain *chain) bool contains(const QmlComponentChain *chain)
{ {
if (!chain || !chain->document()) if (!chain || !chain->document() || !chain->document()->bind())
return false; return false;
if (chain->document()->bind()->idEnvironment()->lookupMember(_name, _scopeChain.context())) const ObjectValue *idEnv = chain->document()->bind()->idEnvironment();
return chain->document()->bind()->idEnvironment() == _scope; if (idEnv && idEnv->lookupMember(_name, _scopeChain.context()))
return idEnv == _scope;
const ObjectValue *root = chain->document()->bind()->rootObjectValue(); const ObjectValue *root = chain->document()->bind()->rootObjectValue();
if (root->lookupMember(_name, _scopeChain.context())) { if (root && root->lookupMember(_name, _scopeChain.context())) {
return check(root); return check(root);
} }