SymbolDatabase: 'const' can't be the name of a variable - fix use after free #5882
This commit is contained in:
parent
e80104327a
commit
e13de2681e
|
@ -2121,7 +2121,7 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
|
||||||
|
|
||||||
// check for argument with no name or missing varid
|
// check for argument with no name or missing varid
|
||||||
if (!endTok) {
|
if (!endTok) {
|
||||||
if (tok->previous()->isName()) {
|
if (tok->previous()->isName() && tok->strAt(-1) != "const") {
|
||||||
if (tok->previous() != typeTok) {
|
if (tok->previous() != typeTok) {
|
||||||
nameTok = tok->previous();
|
nameTok = tok->previous();
|
||||||
endTok = nameTok->previous();
|
endTok = nameTok->previous();
|
||||||
|
|
|
@ -1251,6 +1251,12 @@ private:
|
||||||
ASSERT(g && g->type == Scope::eFunction && g->function && g->function->argumentList.size() == 1 && g->function->argumentList.front().hasDefault());
|
ASSERT(g && g->type == Scope::eFunction && g->function && g->function->argumentList.size() == 1 && g->function->argumentList.front().hasDefault());
|
||||||
ASSERT_EQUALS("", errout.str());
|
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() {
|
void functionArgs2() {
|
||||||
|
|
Loading…
Reference in New Issue