Skip to content

Commit 0bf4ce7

Browse files
authored
Merge pull request #8427 from MathiasVP/fix-bad-join-in-return-stack-allocated-memory
C++: Fix join in `cpp/return-stack-allocated-memory`
2 parents 7c4f9f9 + 7c411b4 commit 0bf4ce7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@ class ReturnStackAllocatedMemoryConfig extends MustFlowConfiguration {
7777

7878
from
7979
MustFlowPathNode source, MustFlowPathNode sink, VariableAddressInstruction var,
80-
ReturnStackAllocatedMemoryConfig conf
80+
ReturnStackAllocatedMemoryConfig conf, Function f
8181
where
8282
conf.hasFlowPath(source, sink) and
8383
source.getNode().asInstruction() = var and
8484
// Only raise an alert if we're returning from the _same_ callable as the on that
8585
// declared the stack variable.
86-
var.getEnclosingFunction() = sink.getNode().getEnclosingCallable()
86+
var.getEnclosingFunction() = pragma[only_bind_into](f) and
87+
sink.getNode().getEnclosingCallable() = pragma[only_bind_into](f)
8788
select sink.getNode(), source, sink, "May return stack-allocated memory from $@.", var.getAst(),
8889
var.getAst().toString()

0 commit comments

Comments
 (0)