Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 015bf6e

Browse files
author
Robert Marsh
committed
C++: Add reverse flow when this ptr is returned
1 parent 2a57fa2 commit 015bf6e

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowUtil.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,19 @@ predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
525525
inner = nodeTo.(InnerPartialDefinitionNode).getPreUpdateNode().asExpr() and
526526
outer = nodeFrom.(PartialDefinitionNode).getPreUpdateNode().asExpr()
527527
)
528+
or
529+
// Reverse flow: data that flows from the post-update node of a reference
530+
// returned by a function call, back into the qualifier of that function.
531+
// This allows data to flow 'in' through references returned by a modeled
532+
// function such as `operator[]`.
533+
exists(DataFlowFunction f, Call call, FunctionInput inModel, FunctionOutput outModel |
534+
call.getTarget() = f and
535+
inModel.isReturnValueDeref() and
536+
outModel.isQualifierObject() and
537+
f.hasDataFlow(inModel, outModel) and
538+
nodeFrom.(PostUpdateNode).getPreUpdateNode().asExpr() = call and
539+
nodeTo.asDefiningArgument() = call.getQualifier()
540+
)
528541
}
529542

530543
/**

0 commit comments

Comments
 (0)