CS.NRE.GEN.CALL.MUSTAn object reference from local assignment of a null-constant or from a call to a function that will return null will be passed to a function that can dereference it, without checking for null. Vulnerability and riskDereferencing a null object reference is a critical runtime problem that will crash the application on some operating systems and throw a runtime exception on others. Example 11 public class A { 2 public void abc() {} 3 public void foo(A a) { 4 if (flag) 5 return; 6 a.abc(); 7 } 8 9 public void var() { 10 A a = null; 11 foo(a); 12 } 13 14 private bool flag; 15 } Klocwork produces an issue report (CS.NRE.GEN.CALL.MUST) at line 11 for variable 'a'. Variable 'a' is explicitly assigned to null value at line 10 and will be passed as argument 1 to function 'foo' at line 11, which may dereference it. |