Fix segfault in template simplifier

When something parsing the template syntax
went wrong, "tok2" was NULL and resulted
in deleting all remaining tokens. Whoops.

Triggered by gcc test suite:
gcc/testsuite/g++.dg/cpp0x/variadic87.C

Tracked down the source of the bug with
valgrind's "--track-origins=yes" switch.
This commit is contained in:
Thomas Jarosch 2015-01-18 01:39:53 +01:00
parent 58cb6cc116
commit cd4c297dce
1 changed files with 5 additions and 0 deletions

View File

@ -658,6 +658,11 @@ void TemplateSimplifier::useDefaultArgumentValues(const std::list<Token *> &temp
if (indentlevel < 0)
break;
}
// something went wrong, don't call eraseTokens()
// with a nullptr "end" parameter (=all remaining tokens).
if (!tok2)
continue;
Token::eraseTokens(eqtok, tok2);
eqtok->deleteThis();
}