Skip to content

Commit bad59f0

Browse files
Fix #13498 assertion in getParentValueTypes (II) / #13707 fuzzing crash (assert) in getParentValueTypes() (#7377)
1 parent fe6549e commit bad59f0

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

lib/symboldatabase.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,9 @@ void SymbolDatabase::createSymbolDatabaseSetTypePointers()
12171217
if (!tok->isName() || tok->varId() || tok->function() || tok->type() || tok->enumerator())
12181218
continue;
12191219

1220+
if (Token::simpleMatch(tok->next(), "<"))
1221+
continue;
1222+
12201223
if (typenames.find(tok->str()) == typenames.end())
12211224
continue;
12221225

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
struct B{o a;B<>{0,{}}}

test/testsymboldatabase.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ class TestSymbolDatabase : public TestFixture {
425425
TEST_CASE(symboldatabase107);
426426
TEST_CASE(symboldatabase108);
427427
TEST_CASE(symboldatabase109); // #13553
428+
TEST_CASE(symboldatabase110);
428429

429430
TEST_CASE(createSymbolDatabaseFindAllScopes1);
430431
TEST_CASE(createSymbolDatabaseFindAllScopes2);
@@ -5760,6 +5761,25 @@ class TestSymbolDatabase : public TestFixture {
57605761
ASSERT(f && f->function() && f->function()->hasVirtualSpecifier());
57615762
}
57625763

5764+
void symboldatabase110() { // #13498
5765+
GET_SYMBOL_DB("struct A;\n"
5766+
"template <typename T, typename C>\n"
5767+
"struct B {\n"
5768+
" const A& a;\n"
5769+
" const std::vector<C>& c;\n"
5770+
"};\n"
5771+
"template <typename T>\n"
5772+
"struct B<T, void> {\n"
5773+
" const A& a;\n"
5774+
"};\n"
5775+
"template <typename T, typename C>\n"
5776+
"void f(const A & a, const std::vector<C>&c) {\n"
5777+
" B<T, C>{ a, c };\n"
5778+
"}\n");
5779+
const Token *B = db ? Token::findsimplematch(tokenizer.tokens(), "B < T , C >") : nullptr;
5780+
ASSERT(B && !B->type());
5781+
}
5782+
57635783
void createSymbolDatabaseFindAllScopes1() {
57645784
GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }");
57655785
ASSERT(db->scopeList.size() == 3);

0 commit comments

Comments
 (0)