File tree Expand file tree Collapse file tree
cpp/misra/src/rules/RULE-8-7-1 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,16 +23,12 @@ import semmle.code.cpp.security.BufferAccess
2323 * A declaration of a variable that is of an array type.
2424 */
2525class ArrayDeclaration extends VariableDeclarationEntry {
26- int length ;
27-
28- ArrayDeclaration ( ) { this .getType ( ) .getUnderlyingType ( ) .( ArrayType ) .getArraySize ( ) = length }
26+ ArrayDeclaration ( ) { this .getType ( ) .getUnderlyingType ( ) instanceof ArrayType }
2927
3028 /**
31- * Gets the declared length of this array.
29+ * Gets the declared length of this array at the given level of indirection .
3230 */
33- int getLength ( ) { result = length }
34-
35- int getLength ( int indirection ) { result = getArrayType ( indirection ) .getArraySize ( ) }
31+ int getLength ( int indirection ) { result = this .getArrayType ( indirection ) .getArraySize ( ) }
3632
3733 private ArrayType getArrayType ( int indirection ) {
3834 indirection = 0 and result = this .getType ( ) .getUnderlyingType ( )
@@ -168,7 +164,7 @@ class ArrayAllocation extends TArrayAllocation {
168164 )
169165 or
170166 node .asUninitialized ( ) = this .asStackAllocation ( ) .getVariable ( ) and
171- result = this .asStackAllocation ( ) .getLength ( )
167+ result = this .asStackAllocation ( ) .getLength ( 0 )
172168 or
173169 node .asConvertedExpr ( ) = this .asDynamicAllocation ( ) and
174170 result = this .asDynamicAllocation ( ) .getMinNumElements ( )
You can’t perform that action at this time.
0 commit comments