[previous] 2811 [next] Definite: Dereference of NULL pointer.
NULL pointers

A definite anomaly has been detected. Examination of the context indicates that this expression will always result in the dereferencing of a null pointer. The result of any attempt to dereference a null pointer value is undefined.

In the example below, p is NULL throughout the code contained in the "if" block and the result of the dereferencing operation will always be undefined.


/*PRQA S 504,2017,2983,2986,3199,3203,3227,3408,3412,3673,4600 ++*/
#define NULL (void *)0

void foo(int *p)
{
    int r;

    if (p == NULL)
    {
        r = *p;             /* 2811 */
    }
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents