Skip to content

Commit 88be4b8

Browse files
committed
C++: Address review comments
1 parent 2068591 commit 88be4b8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cpp/ql/src/experimental/Best Practices/GuardedFree.ql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ predicate blockContainsPreprocessorBranches(BasicBlock bb) {
2222
exists(PreprocessorBranch ppb, Location bbLoc, Location ppbLoc |
2323
bbLoc = bb.(Stmt).getLocation() and ppbLoc = ppb.getLocation()
2424
|
25+
bbLoc.getFile() = ppb.getFile() and
2526
bbLoc.getStartLine() < ppbLoc.getStartLine() and
2627
ppbLoc.getEndLine() < bbLoc.getEndLine()
2728
)
@@ -33,8 +34,10 @@ where
3334
fc.getArgument(0) = v.getAnAccess() and
3435
bb = fc.getBasicBlock() and
3536
(
37+
// No block statement: if (x) free(x);
3638
bb = fc.getEnclosingStmt()
3739
or
40+
// Block statement with a single nested statement: if (x) { free(x); }
3841
strictcount(bb.(BlockStmt).getAStmt()) = 1
3942
) and
4043
strictcount(BasicBlock bb2 | gc.ensuresEq(_, 0, bb2, _) | bb2) = 1 and

0 commit comments

Comments
 (0)