Skip to content

Commit

Permalink
C++: Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jketema committed Nov 18, 2024
1 parent 2068591 commit 88be4b8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cpp/ql/src/experimental/Best Practices/GuardedFree.ql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ predicate blockContainsPreprocessorBranches(BasicBlock bb) {
exists(PreprocessorBranch ppb, Location bbLoc, Location ppbLoc |
bbLoc = bb.(Stmt).getLocation() and ppbLoc = ppb.getLocation()
|
bbLoc.getFile() = ppb.getFile() and
bbLoc.getStartLine() < ppbLoc.getStartLine() and
ppbLoc.getEndLine() < bbLoc.getEndLine()
)
Expand All @@ -33,8 +34,10 @@ where
fc.getArgument(0) = v.getAnAccess() and
bb = fc.getBasicBlock() and
(
// No block statement: if (x) free(x);
bb = fc.getEnclosingStmt()
or
// Block statement with a single nested statement: if (x) { free(x); }
strictcount(bb.(BlockStmt).getAStmt()) = 1
) and
strictcount(BasicBlock bb2 | gc.ensuresEq(_, 0, bb2, _) | bb2) = 1 and
Expand Down

0 comments on commit 88be4b8

Please sign in to comment.