Skip to content

Commit fc24f76

Browse files
Fix #11627 Infinite loop in ReverseTraversal (#4916)
1 parent 13e12da commit fc24f76

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

lib/reverseanalyzer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ struct ReverseTraversal {
7878
return nullptr;
7979
if (ftok->index() >= tok->index())
8080
return nullptr;
81-
if (ftok->link())
82-
ftok = ftok->link()->next();
83-
else
81+
if (!ftok->link() || ftok->str() == ")")
8482
ftok = ftok->next();
83+
else
84+
ftok = ftok->link()->next();
8585
}
8686
if (ftok == tok)
8787
return nullptr;

test/testvalueflow.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6980,6 +6980,11 @@ class TestValueFlow : public TestFixture {
69806980
" void g(std::vector<int> (*f) () = nullptr);\n"
69816981
"};\n";
69826982
valueOfTok(code, "=");
6983+
6984+
code = "void f(bool b) {\n" // #11627
6985+
" (*printf)(\"%s %i\", strerror(errno), b ? 0 : 1);\n"
6986+
"};\n";
6987+
valueOfTok(code, "?");
69836988
}
69846989

69856990
void valueFlowHang() {

0 commit comments

Comments
 (0)