Skip to content

Commit 14faa5d

Browse files
committed
C++: Fix off-by-one in 'asDefiningArgument' so that the domain of the argument is '[1..]' like 'asIndirectArgument'.
1 parent 12a717e commit 14faa5d

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,7 @@ class Node extends TIRDataFlowNode {
254254
* after the `f` has returned.
255255
*/
256256
Expr asDefiningArgument(int index) {
257-
// Subtract one because `DefinitionByReferenceNode` is defined to be in
258-
// the range `[0 ... n - 1]` for some `n` instead of `[1 ... n]`.
259-
this.(DefinitionByReferenceNode).getIndirectionIndex() = index - 1 and
257+
this.(DefinitionByReferenceNode).getIndirectionIndex() = index and
260258
result = this.(DefinitionByReferenceNode).getArgument()
261259
}
262260

0 commit comments

Comments
 (0)