I have one method in c#. Before calling method i checked not null condition of the parameter. But inside the method i didn’t check null condition. why it’s showing as bug? because i checked before calling a function. both the functions are in same file?
Example:
int[] data=null;
public void F1()
{
if(data != null)
F2(data);
}
public void F2(int[] p1)
{
var res=p1[0];
}
Thank you for reaching out to us.
For the time being we don’t support cross method analysis. So, our analyzer does not know that a null check was done before the invocation.
On the other hand I would not call this a false positive, because there might be other invocations of F2 without the null check in place. I suggest to move the check inside F2.