Skip to content

Commit 0a35f97

Browse files
authored
Merge pull request #9872 from jketema/return-join
C++: Fix join-order problem in `cpp/return-stack-allocated-memory`
2 parents 23c1931 + ad8335d commit 0a35f97

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,12 @@ class ReturnStackAllocatedMemoryConfig extends MustFlowConfiguration {
7474

7575
from
7676
MustFlowPathNode source, MustFlowPathNode sink, VariableAddressInstruction var,
77-
ReturnStackAllocatedMemoryConfig conf, Function f
77+
ReturnStackAllocatedMemoryConfig conf
7878
where
79-
conf.hasFlowPath(source, sink) and
79+
conf.hasFlowPath(pragma[only_bind_into](source), pragma[only_bind_into](sink)) and
8080
source.getNode().asInstruction() = var and
8181
// Only raise an alert if we're returning from the _same_ callable as the on that
8282
// declared the stack variable.
83-
var.getEnclosingFunction() = pragma[only_bind_into](f) and
84-
sink.getNode().getEnclosingCallable() = pragma[only_bind_into](f)
83+
var.getEnclosingFunction() = sink.getNode().getEnclosingCallable()
8584
select sink.getNode(), source, sink, "May return stack-allocated memory from $@.", var.getAst(),
8685
var.getAst().toString()

0 commit comments

Comments
 (0)