Skip to content

Commit

Permalink
Fix autovarInvalidDeallocation regression
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jun 27, 2023
1 parent 9dc38f8 commit a110fa0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/checkautovariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ void CheckAutoVariables::autoVariables()
if (v.isImpossible())
continue;
if ((v.isTokValue() && (isArrayVar(v.tokvalue) || ((v.tokvalue->tokType() == Token::eString)))) ||
(v.isLocalLifetimeValue() && v.lifetimeKind == ValueFlow::Value::LifetimeKind::Address)) {
(v.isLocalLifetimeValue() && v.lifetimeKind == ValueFlow::Value::LifetimeKind::Address && !Token::simpleMatch(v.tokvalue, "("))) {
errorInvalidDeallocation(tok, &v);
break;
}
Expand Down
6 changes: 6 additions & 0 deletions test/testautovariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,12 @@ class TestAutoVariables : public TestFixture {
" return 0;\n"
"}\n");
ASSERT_EQUALS("", errout.str());

check("void f() {\n"
" S* p = &g();\n"
" delete p;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}

void testinvaliddealloc_input() {
Expand Down

0 comments on commit a110fa0

Please sign in to comment.