Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #12510 fuzzing crash in SymbolDatabase::setValueTypeInTokenList() #6161

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading