Arithmetic operation performed on NULL pointer
This defect occurs
when an arithmetic operation involves a pointer whose value is NULL.
Performing pointer arithmetic on a null pointer and dereferencing the resulting pointer is undefined behavior. In most implementations, the dereference can cause your program to crash.
Check a pointer for NULL before arithmetic operations on the
pointer.
If the issue occurs despite an earlier check for NULL, look for
intermediate events between the check and the subsequent dereference. Often the
result details show a sequence of events that led to the defect. You can implement
the fix on any event in the sequence. If the result details do not show the event
history, you can trace back using right-click options in the source code and see
previous related events. See also Interpret Bug Finder Results in Polyspace Desktop User Interface.
See examples of fixes below.
| Group: Static memory |
| Language: C | C++ |
| Default: Off |
Command-Line Syntax: NULL_PTR_ARITH |
| Impact: Low |