Skip to content

Commit

Permalink
Fix #12510 fuzzing crash in SymbolDatabase::setValueTypeInTokenList()
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Mar 20, 2024
1 parent e2081e8 commit 07acbe9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2558,11 +2558,11 @@ Function::Function(const Token *tok,
}

// class constructor/destructor
else if (((tokenDef->str() == scope->className) ||
else if (scope->isClassOrStructOrUnion() &&
((tokenDef->str() == scope->className) ||
(tokenDef->str().substr(0, scope->className.size()) == scope->className &&
tokenDef->str().size() > scope->className.size() + 1 &&
tokenDef->str()[scope->className.size() + 1] == '<')) &&
scope->type != Scope::ScopeType::eNamespace) {
tokenDef->str()[scope->className.size() + 1] == '<'))) {
// destructor
if (tokenDef->previous()->str() == "~")
type = Function::eDestructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
o oo(){extern oo();}
6 changes: 6 additions & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2239,6 +2239,12 @@ class TestSymbolDatabase : public TestFixture {
ASSERT(db && ctor && ctor->type == Function::eMoveConstructor);
ASSERT(ctor && ctor->retDef == nullptr);
}
{
GET_SYMBOL_DB("void f() { extern void f(); }");
ASSERT(db && db->scopeList.size() == 2);
const Function* f = findFunctionByName("f", &db->scopeList.back());
ASSERT(f && f->type == Function::eFunction);
}
}

void functionDeclarationTemplate() {
Expand Down

0 comments on commit 07acbe9

Please sign in to comment.