File tree Expand file tree Collapse file tree 2 files changed +9
-14
lines changed
cpp/common/src/codingstandards/cpp/resources
c/misra/test/rules/RULE-22-16 Expand file tree Collapse file tree 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) {
104104 }
105105 mtx_unlock (& m );
106106 }
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 );
107115}
Original file line number Diff line number Diff line change @@ -64,19 +64,6 @@ module ResourceLeak<ResourceLeakConfigSig Config> {
6464 Config:: isAllocate ( cfgNode , resource )
6565 }
6666
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-
8067 private predicate isLeakedAtControlPoint ( TResource resource , ControlFlowNode cfgNode ) {
8168 // Holds if this control point is where the resource was allocated (and therefore not freed).
8269 resource = TJustResource ( _, cfgNode )
@@ -86,7 +73,7 @@ module ResourceLeak<ResourceLeakConfigSig Config> {
8673 isLeakedAtControlPoint ( resource , cfgNode .getAPredecessor ( ) ) and
8774 not exists ( DataFlow:: Node freed , DataFlow:: Node resourceNode |
8875 Config:: isFree ( cfgNode , freed ) and
89- freed = getAnAliasRecursive ( resourceNode ) and
76+ freed = Config :: getAnAlias ( resourceNode ) and
9077 resource = TJustResource ( resourceNode , _)
9178 )
9279 }
You can’t perform that action at this time.
0 commit comments