[previous] 2814 [next] Possible: Dereference of NULL pointer.
NULL pointers

A possible dataflow condition has been identified.

The result of any attempt to dereference a null pointer value is undefined.

For example:

/*PRQA S 506,2017,2983,2986,3199,3203,3227,3408,3602,3673,4600 ++*/

#define NULL (void *)0

void foo(int *p, int *q)
{
    int m;
    int n;

    m = *p;                     /* 2814 */ /* p could be a null pointer */

    if (q == NULL)
    {
        n = 0;
    }
    else
    {
        n = *q;                 /*      */ /* q is NOT null at this point */
    }
}

See also:

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