Skip to content

Commit 1c86573

Browse files
Remove getAnAliasRecursive()
1 parent 2f619a4 commit 1c86573

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

c/misra/test/rules/RULE-22-16/test.c

+8
Original file line numberDiff line numberDiff 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
}

cpp/common/src/codingstandards/cpp/resources/ResourceLeakAnalysis.qll

+1-14
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)