summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus/CheckName.cpp
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-11-11 16:34:41 +0100
committerRoberto Raggi <roberto.raggi@nokia.com>2009-11-11 16:35:18 +0100
commita1f9b0513523e79feb2c93e590d5fe9dbfed64ee (patch)
tree40b6a4754ac8e8b7d93ca133d7e3b3271a2a29d3 /src/shared/cplusplus/CheckName.cpp
parentc7cd56c5d5eadc9d6f22faeee505e71594c4951e (diff)
downloadqt-creator-a1f9b0513523e79feb2c93e590d5fe9dbfed64ee.tar.gz
Fixed possible crash in CheckName
Done with: Erik Verbruggen
Diffstat (limited to 'src/shared/cplusplus/CheckName.cpp')
-rw-r--r--src/shared/cplusplus/CheckName.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/shared/cplusplus/CheckName.cpp b/src/shared/cplusplus/CheckName.cpp
index 6476b3295f..63a1885128 100644
--- a/src/shared/cplusplus/CheckName.cpp
+++ b/src/shared/cplusplus/CheckName.cpp
@@ -378,12 +378,14 @@ bool CheckName::visit(TemplateIdAST *ast)
bool CheckName::visit(ObjCSelectorWithoutArgumentsAST *ast)
{
- std::vector<Name *> names;
- Identifier *id = control()->findOrInsertIdentifier(spell(ast->name_token));
- NameId *nameId = control()->nameId(id);
- names.push_back(nameId);
- _name = control()->selectorNameId(&names[0], names.size(), false);
- ast->selector_name = _name;
+ if (ast->name_token) {
+ std::vector<Name *> names;
+ Identifier *id = control()->findOrInsertIdentifier(spell(ast->name_token));
+ NameId *nameId = control()->nameId(id);
+ names.push_back(nameId);
+ _name = control()->selectorNameId(&names[0], names.size(), false);
+ ast->selector_name = _name;
+ }
return false;
}
@@ -392,9 +394,14 @@ bool CheckName::visit(ObjCSelectorWithArgumentsAST *ast)
{
std::vector<Name *> names;
for (ObjCSelectorArgumentListAST *it = ast->selector_argument_list; it; it = it->next) {
- Identifier *id = control()->findOrInsertIdentifier(spell(it->value->name_token));
- NameId *nameId = control()->nameId(id);
- names.push_back(nameId);
+ if (it->value->name_token) {
+ Identifier *id = control()->findOrInsertIdentifier(spell(it->value->name_token));
+ NameId *nameId = control()->nameId(id);
+ names.push_back(nameId);
+ } else {
+ // we have an incomplete name due, probably due to error recovery. So, back out completely
+ return false;
+ }
}
if (!names.empty()) {