Merge pull request #8427 from MathiasVP/fix-bad-join-in-return-stack-allocated-memory

C++: Fix join in `cpp/return-stack-allocated-memory`
This commit is contained in:
Mathias Vorreiter Pedersen
2022-03-14 12:49:30 +00:00
committed by GitHub

View File

@@ -77,12 +77,13 @@ class ReturnStackAllocatedMemoryConfig extends MustFlowConfiguration {
from
MustFlowPathNode source, MustFlowPathNode sink, VariableAddressInstruction var,
ReturnStackAllocatedMemoryConfig conf
ReturnStackAllocatedMemoryConfig conf, Function f
where
conf.hasFlowPath(source, sink) and
source.getNode().asInstruction() = var and
// Only raise an alert if we're returning from the _same_ callable as the on that
// declared the stack variable.
var.getEnclosingFunction() = sink.getNode().getEnclosingCallable()
var.getEnclosingFunction() = pragma[only_bind_into](f) and
sink.getNode().getEnclosingCallable() = pragma[only_bind_into](f)
select sink.getNode(), source, sink, "May return stack-allocated memory from $@.", var.getAst(),
var.getAst().toString()