SA0039: Possible null-pointer deferences

Detects code locations where a null pointer is possibly dereferenced

Justification: A pointer should be checked before each dereferencing to make sure it is not equal to zero. Otherwise an "access violation" may occur at runtime.

Importance: High

Example

PROGRAM PLC_PRG
VAR
        ptiVar1:POINTER TO INT;
        ptiVar2:POINTER TO INT;
        ptiVar3:POINTER TO INT;
        iVar:INT;
        iCount :INT;
        iCondition: INT;
END_VAR

iCount := iCount + INT#1;
ptiVar1 := ADR(iVar);
ptiVar1^ := iCondition; // OK - valid reference
ptiVar2^ := iCondition; // SA0039 - null pointer dereferenciation
iVar := ptiVar3^;       // SA0039 - null pointer dereferenciation

--> SA0039: Mögliche Null-Pointer-Dereferenzierung 'ptiVar2^'
--> SA0039: Mögliche Null-Pointer-Dereferenzierung 'ptiVar3^'