SARIF SDK

NullReferenceException is possible

V3083 [CWE-367] Unsafe invocation of event ‘RuleRead’, NullReferenceException is possible. Consider assigning event to a local variable before invoking it. FxCopConverter.cs 897

private void ReadRule(....)
{
  ....
  if (RuleRead != null)
  {
    RuleRead(....);
  }
  ....
}

Events are handled unsafely. It’s an uncritical bug that can be easily fixed, for example, by following the Visual Studio tip. Here’s the replacement suggested by the IDE:

private void ReadRule(....)
{
  ....
  RuleRead?.Invoke(....);
  ....
}

Please click here to see more bugs from this project.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.