what is difference betwen REVERSE_INULL and FORWARD_NULL error in coverity scan(static code analysis)?

4.4k Views Asked by At

when i run coverity scan on python code (static code analysis), REVERSE_INULL and FORWARD_NULL error are detected. can anyone tell what is difference between REVERSE_INULL and FORWARD_NULL ? why these error are detected.

1

There are 1 best solutions below

0
On

REVERSE_INULL means that you have a dereference followed by a null-type check.

In pseudo code

x := null
...
x.deref
...
if x is null
    # handle null-type x

The fix would be to put the null-type check before the dereference.

FORWARD_NULL is simply where there is a path for a null-valued variable to be dereferenced. Another pseudo-code example

x := null
...
if x is null
    print warning
    # but x is still null

x.deref

Here you have to ensure that the null-ness is always handled.

So ultimately I'd say that REVERSE_INULL does the same null dereference checking as FORWARD_NULL but that it additionally detects a check after the dereference.

(standard disclaimer - I used to work for Synopsys, but not the division producing Coverity).