SymbolDatabase: 'const' can't be the name of a variable - fix use after free #5882

This commit is contained in:
PKEuS 2014-06-26 09:16:55 +02:00
parent e80104327a
commit e13de2681e
2 changed files with 7 additions and 1 deletions

View File

@ -2121,7 +2121,7 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
// check for argument with no name or missing varid
if (!endTok) {
if (tok->previous()->isName()) {
if (tok->previous()->isName() && tok->strAt(-1) != "const") {
if (tok->previous() != typeTok) {
nameTok = tok->previous();
endTok = nameTok->previous();

View File

@ -1251,6 +1251,12 @@ private:
ASSERT(g && g->type == Scope::eFunction && g->function && g->function->argumentList.size() == 1 && g->function->argumentList.front().hasDefault());
ASSERT_EQUALS("", errout.str());
}
{
GET_SYMBOL_DB("void g(int* const) { }"); // 'const' is not the name of the variable - #5882
const Scope* g = db->findScopeByName("g");
ASSERT(g && g->type == Scope::eFunction && g->function && g->function->argumentList.size() == 1 && g->function->argumentList.front().nameToken() == nullptr);
ASSERT_EQUALS("", errout.str());
}
}
void functionArgs2() {