Pointer is dereferenced outside bounds
This check on a pointer dereference determines whether the pointer is NULL or points outside its bounds. The check occurs only when you dereference a pointer and not when you reassign to another pointer or pass the pointer to a function.
The check message shows you the pointer offset and buffer size in bytes. A pointer points outside its bounds when the sum of the offset and pointer size exceeds the buffer size.
Buffer: When you assign an address to a pointer, a block of memory is allocated to the pointer. You cannot access memory beyond that block using the pointer. The size of this block is the buffer size.
Sometimes, instead of a definite value, the size can be a range. For
instance, if you create a buffer dynamically using malloc
with an unknown input for the size, Polyspace® assumes that the array size can take the full range of values
allowed by the input data type.
Offset: You can move a pointer within the allowed memory block by using pointer arithmetic. The difference between the initial location of the pointer and its current location is the offset.
Sometimes, instead of a definite value, the offset can be a range. For instance, if you access an array in a loop, the offset changes value in each loop iteration and takes a range of values throughout the loop.
For instance, if the pointer points to an array:
The buffer size is the array size.
The offset is the difference between the beginning of the array and the current location of the pointer.
| Group: Static memory |
| Language: C | C++ |
| Acronym: IDP |