[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 */
    }
}


No MISRA C:2012 Rules applicable to message 2814


See also:

QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents