Skip to content

Commit

Permalink
Fix #12716 Assert failure in updateRange() (#6580)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Jul 10, 2024
1 parent 5a20a51 commit b9912e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,8 @@ static T* getCondTokImpl(T* tok)
return tok->next()->astOperand2()->astOperand2()->astOperand1();
if (Token::simpleMatch(tok->next()->astOperand2(), ";"))
return tok->next()->astOperand2()->astOperand1();
if (tok->isName() && !tok->isControlFlowKeyword())
return nullptr;
return tok->next()->astOperand2();
}

Expand Down
10 changes: 10 additions & 0 deletions test/testvalueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7467,6 +7467,16 @@ class TestValueFlow : public TestFixture {

code = "void f() { int& a = *&a; }\n"; // #12511
valueOfTok(code, "=");

code = "void g(int*);\n" // #12716
"void f(int a) {\n"
" do {\n"
" if (a)\n"
" break;\n"
" g((int[256]) { 0 });\n"
" } while (true);\n"
"}\n";
valueOfTok(code, "0");
}

void valueFlowHang() {
Expand Down

0 comments on commit b9912e0

Please sign in to comment.