ArrayBound -- Access to an Element Out of Array's Boundaries

From RAD Studio
Jump to: navigation, search

Go Up to C++ Audits

Description

This audit checks whether an array index expression is out of the array's boundaries. For example, this violation can mean that the index expression either always produces negative values, or its minimal value is greater than or equal to the maximum possible length of the accessed array.

The ArrayBound audit is the counterpart to ArrayBoundV2 -- Access to an Element Out of Array's Boundaries.

Incorrect

 int arr[5];
 int find(int low) {
   if (low < 0) {
      arr[low] = 0;
   }
   ...
 }

See Also