Skip to content

Commit 7c411b4

Browse files
authored
C++: Respond to review comments
1 parent 31b1e40 commit 7c411b4

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

cpp/ql/src/Likely Bugs/Memory Management/ReturnStackAllocatedMemory.ql

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@ class ReturnStackAllocatedMemoryConfig extends MustFlowConfiguration {
7575
}
7676
}
7777

78-
predicate instrHasEnclosingCallable(VariableAddressInstruction var, Function f) {
79-
f = var.getEnclosingFunction()
80-
}
81-
82-
predicate nodeHasEnclosingCallable(DataFlow::Node node, Function f) {
83-
f = node.getEnclosingCallable()
84-
}
85-
8678
from
8779
MustFlowPathNode source, MustFlowPathNode sink, VariableAddressInstruction var,
8880
ReturnStackAllocatedMemoryConfig conf, Function f
@@ -91,7 +83,7 @@ where
9183
source.getNode().asInstruction() = var and
9284
// Only raise an alert if we're returning from the _same_ callable as the on that
9385
// declared the stack variable.
94-
instrHasEnclosingCallable(var, pragma[only_bind_into](f)) and
95-
nodeHasEnclosingCallable(sink.getNode(), pragma[only_bind_into](f))
86+
var.getEnclosingFunction() = pragma[only_bind_into](f) and
87+
sink.getNode().getEnclosingCallable() = pragma[only_bind_into](f)
9688
select sink.getNode(), source, sink, "May return stack-allocated memory from $@.", var.getAst(),
9789
var.getAst().toString()

0 commit comments

Comments
 (0)