File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1892,6 +1892,8 @@ bool Library::isSmartPointer(const Token* tok) const
18921892
18931893const Library::SmartPointer* Library::detectSmartPointer (const Token* tok, bool withoutStd) const
18941894{
1895+ if (!tok)
1896+ return nullptr ;
18951897 std::string typestr = withoutStd ? " std::" : " " ;
18961898 if (tok->str () == " ::" )
18971899 tok = tok->next ();
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ class TestLibrary : public TestFixture {
6969 TEST_CASE (version);
7070 TEST_CASE (loadLibErrors);
7171 TEST_CASE (loadLibCombinations);
72+ TEST_CASE (smartpointer);
7273 }
7374
7475 void isCompliantValidationExpression () const {
@@ -868,6 +869,8 @@ class TestLibrary : public TestFixture {
868869 ASSERT_EQUALS (F.endPattern , " " );
869870 ASSERT_EQUALS (F.itEndPattern , " :: iterator" );
870871
872+ ASSERT (!library.detectContainerOrIterator (nullptr ));
873+
871874 {
872875 const SimpleTokenizer var (*this , " std::A<int> a;" );
873876 ASSERT_EQUALS (&A, library.detectContainer (var.tokens ()));
@@ -1140,6 +1143,15 @@ class TestLibrary : public TestFixture {
11401143 ASSERT_EQUALS (s.library .defines ().empty (), false );
11411144 }
11421145 }
1146+
1147+ void smartpointer () const {
1148+ const Settings s = settingsBuilder ().library (" std.cfg" ).build ();
1149+ const Library& library = s.library ;
1150+
1151+ ASSERT (!library.detectSmartPointer (nullptr ));
1152+
1153+ // TODO: add more tests
1154+ }
11431155};
11441156
11451157REGISTER_TEST (TestLibrary)
Original file line number Diff line number Diff line change @@ -612,6 +612,8 @@ class TestSymbolDatabase : public TestFixture {
612612 TEST_CASE(testValuetypeOriginalName);
613613
614614 TEST_CASE(dumpFriend); // Check if isFriend added to dump file
615+
616+ TEST_CASE(smartPointerLookupCtor); // #13719);
615617 }
616618
617619 void array() {
@@ -11190,6 +11192,14 @@ class TestSymbolDatabase : public TestFixture {
1119011192 db->printXml(ostr);
1119111193 ASSERT(ostr.str().find(" isFriend=\"true\"") != std::string::npos);
1119211194 }
11195+
11196+ void smartPointerLookupCtor() { // #13719
11197+ // do not crash in smartpointer lookup
11198+ GET_SYMBOL_DB("struct S { int v; S(int i); };\n"
11199+ "void f() { S(0).v; }");
11200+
11201+ ASSERT(db);
11202+ }
1119311203};
1119411204
1119511205REGISTER_TEST(TestSymbolDatabase)
You can’t perform that action at this time.
0 commit comments