File tree 2 files changed +9
-14
lines changed
c/misra/test/rules/RULE-22-16
cpp/common/src/codingstandards/cpp/resources
2 files changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -104,4 +104,12 @@ void f15(int p) {
104
104
}
105
105
mtx_unlock (& m );
106
106
}
107
+ }
108
+
109
+ void f16 (int p ) {
110
+ mtx_t * ptr ;
111
+ mtx_t * ptr_m1 = ptr ;
112
+ mtx_t * ptr_m2 = ptr ;
113
+ mtx_lock (ptr_m1 ); // COMPLIANT[FALSE_POSITIVE]
114
+ mtx_unlock (ptr_m2 );
107
115
}
Original file line number Diff line number Diff line change @@ -64,19 +64,6 @@ module ResourceLeak<ResourceLeakConfigSig Config> {
64
64
Config:: isAllocate ( cfgNode , resource )
65
65
}
66
66
67
- /**
68
- * Get an alias of a resource, and aliases of nodes that are aliased by a resource.
69
- */
70
- private DataFlow:: Node getAnAliasRecursive ( DataFlow:: Node node ) {
71
- result = Config:: getAnAlias ( node ) and
72
- Config:: isAllocate ( _, node )
73
- or
74
- exists ( DataFlow:: Node parent |
75
- node = getAnAliasRecursive ( parent ) and
76
- result = Config:: getAnAlias ( parent )
77
- )
78
- }
79
-
80
67
private predicate isLeakedAtControlPoint ( TResource resource , ControlFlowNode cfgNode ) {
81
68
// Holds if this control point is where the resource was allocated (and therefore not freed).
82
69
resource = TJustResource ( _, cfgNode )
@@ -86,7 +73,7 @@ module ResourceLeak<ResourceLeakConfigSig Config> {
86
73
isLeakedAtControlPoint ( resource , cfgNode .getAPredecessor ( ) ) and
87
74
not exists ( DataFlow:: Node freed , DataFlow:: Node resourceNode |
88
75
Config:: isFree ( cfgNode , freed ) and
89
- freed = getAnAliasRecursive ( resourceNode ) and
76
+ freed = Config :: getAnAlias ( resourceNode ) and
90
77
resource = TJustResource ( resourceNode , _)
91
78
)
92
79
}
You can’t perform that action at this time.
0 commit comments