Skip to content

Commit

Permalink
Fix #12511 fuzzing crash (stack overflow) in getLibraryContainer() (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Mar 21, 2024
1 parent 91f1a25 commit e25c512
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4972,6 +4972,8 @@ static void valueFlowLifetime(TokenList &tokenlist, ErrorLogger *errorLogger, co
}
// address of
else if (tok->isUnaryOp("&")) {
if (Token::simpleMatch(tok->astParent(), "*"))
continue;
for (const ValueFlow::LifetimeToken& lt : ValueFlow::getLifetimeTokens(tok->astOperand1())) {
if (!settings.certainty.isEnabled(Certainty::inconclusive) && lt.inconclusive)
continue;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d o(){t&a=*&a}
3 changes: 3 additions & 0 deletions test/testvalueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7434,6 +7434,9 @@ class TestValueFlow : public TestFixture {
" if (*q > 0 && *q < 100) {}\n"
"}\n";
valueOfTok(code, "&&");

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

void valueFlowHang() {
Expand Down

0 comments on commit e25c512

Please sign in to comment.