TemplateSimplifier: Fixed crash caused by null pointer dereference. I don't have a testcase. But the code is suspicious, in the loop we check if tok3 is null and then in the loop head we call tok3->next().

This commit is contained in:
Daniel Marjamäki 2014-07-15 21:28:52 +02:00
parent c531749d7a
commit d41ef3a6d0
1 changed files with 2 additions and 2 deletions

View File

@ -708,7 +708,7 @@ void TemplateSimplifier::expandTemplate(
std::vector<const Token *> &typesUsedInTemplateInstantiation,
std::list<Token *> &templateInstantiations)
{
for (const Token *tok3 = tokenlist.front(); tok3; tok3 = tok3->next()) {
for (const Token *tok3 = tokenlist.front(); tok3; tok3 = tok3 ? tok3->next() : nullptr) {
if (tok3->str() == "{" || tok3->str() == "(" || tok3->str() == "[")
tok3 = tok3->link();
@ -720,7 +720,7 @@ void TemplateSimplifier::expandTemplate(
// member function implemented outside class definition
else if (TemplateSimplifier::instantiateMatch(tok3, name, typeParametersInDeclaration.size(), ":: ~| %var% (")) {
tokenlist.addtoken(newName, tok3->linenr(), tok3->fileIndex());
while (tok3->str() != "::")
while (tok3 && tok3->str() != "::")
tok3 = tok3->next();
}