File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import semmle.code.cpp.pointsto.PointsTo
22
33private predicate freed ( Expr e ) {
4- exists ( FunctionCall fc , Expr arg |
5- freeCall ( fc , arg ) and
6- arg = e
7- )
8- or
9- exists ( DeleteExpr de | de .getExpr ( ) = e )
10- or
11- exists ( DeleteArrayExpr de | de .getExpr ( ) = e )
4+ e = any ( DeallocationExpr de ) .getFreedExpr ( )
125 or
136 exists ( ExprCall c |
147 // cautiously assume that any ExprCall could be a freeCall.
@@ -22,7 +15,6 @@ class FreedExpr extends PointsToExpr {
2215 override predicate interesting ( ) { freed ( this ) }
2316}
2417
25- predicate allocMayBeFreed ( Expr alloc ) {
26- isAllocationExpr ( alloc ) and
18+ predicate allocMayBeFreed ( AllocationExpr alloc ) {
2719 anythingPointsTo ( alloc )
2820}
Original file line number Diff line number Diff line change 1111
1212import MemoryFreed
1313
14- from Expr alloc
15- where isAllocationExpr ( alloc ) and not allocMayBeFreed ( alloc )
14+ from AllocationExpr alloc
15+ where
16+ alloc .requiresDealloc ( ) and
17+ not exists ( alloc .( NewOrNewArrayExpr ) .getPlacementPointer ( ) ) and
18+ not allocMayBeFreed ( alloc )
1619select alloc , "This memory is never freed"
You can’t perform that action at this time.
0 commit comments