Skip to content

Commit f2f6110

Browse files
author
Nikita Kraiouchkine
committed
Update DoNotAddOrSubtractAScaledIntegerToAPointer.ql
Exclude instances of ArrayCountOfExpr where 'arr' is a pointer rather than array type
1 parent 2fc17ae commit f2f6110

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

c/cert/src/rules/ARR39-C/DoNotAddOrSubtractAScaledIntegerToAPointer.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ class ArrayCountOfExpr extends ArrayExpr {
6464
exists(DivExpr div, Variable arr, VariableAccess left, ArrayExpr right |
6565
div = this.getArrayOffset() and
6666
arr = this.getArrayBase().(VariableAccess).getTarget() and
67+
// exclude cases where arr is a pointer rather than an array
68+
arr.getUnderlyingType() instanceof ArrayType and
6769
// holds if the dividend is sizeof(arr)
6870
left = div.getLeftOperand().(SizeofExprOperator).getExprOperand() and
6971
left.getTarget() = this.getArrayBase().(VariableAccess).getTarget() and

0 commit comments

Comments
 (0)