C++: Also allow single statement blocks in cpp/guarded-free

This commit is contained in:
Jeroen Ketema
2024-11-14 12:47:29 +01:00
parent c86bbbb063
commit a31e983e9e
3 changed files with 13 additions and 3 deletions

View File

@@ -22,6 +22,11 @@ from GuardCondition gc, FreeCall fc, Variable v, BasicBlock bb
where
gc.ensuresEq(v.getAnAccess(), 0, bb, false) and
fc.getArgument(0) = v.getAnAccess() and
bb = fc.getEnclosingStmt() and
bb = fc.getBasicBlock() and
(
bb = fc.getEnclosingStmt()
or
strictcount(bb.(BlockStmt).getAStmt()) = 1
) and
strictcount(BasicBlock bb2 | gc.ensuresEq(_, 0, bb2, _) | bb2) = 1
select gc, "unnecessary NULL check before call to $@", fc, "free"