Our website uses cookies to enhance your browsing experience.
Accept
to the top
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
>
Examples of errors detected by the V309…

Examples of errors detected by the V3095 diagnostic

V3095. The object was used before it was verified against null. Check lines: N1, N2.


Barotrauma

V3095. The 'FixtureA' object was used before it was verified against null. Check lines: 252, 255. Contact.cs 252.


public class Contact
{
  ....
  public Fixture FixtureA { get; internal set; }
  ....
  internal void Update(ContactManager contactManager)
  {
    Body bodyA = FixtureA.Body;
    ....
    if (FixtureA == null || ....) // <=
      return;
    ....
    if (....)
    {
      Shape shapeA = FixtureA.Shape;
      ....
      touching = Collision.Collision.TestOverlap(...., ref bodyA._xf, ....);
      ....
    }
  }
}

Barotrauma

V3095. The 'FixtureB' object was used before it was verified against null. Check lines: 253, 255. Contact.cs 253.


public class Contact
{
  ....
  public Fixture FixtureB { get; internal set; }
  ....
  internal void Update(ContactManager contactManager)
  {
    ....
    Body bodyB = FixtureB.Body;

    if (.... || FixtureB == null) // <=
      return;
    ....
    if (....)
    {
      ....
      Shape shapeB = FixtureB.Shape;
      touching = Collision.Collision.TestOverlap(...., ref bodyB._xf);
      ....
    }
  }
}

Stride

V3095 The 'materialFilterRenderFeature' object was used before it was verified against null. EditorGameRenderModeService.cs 106, 107.


private async Task Update()
{
  while (....)
  {
    ....
    if (....)
    {
      ....
      materialFilterRenderFeature.MaterialFilter =
        (materialFilterRenderFeature != null && ....)? ....
      ....
    }
  }
}

Stride

V3095 The 'window' object was used before it was verified against null. GameWindowSDL.cs 64, 70.


public override void EndScreenDeviceChange(....)
{
  ....
  window.FullscreenIsBorderlessWindow = FullscreenIsBorderlessWindow; // <=
  if (....)
  {
    ....
    if (window != null)
    {
      window.ClientSize = new Size2(clientWidth, clientHeight);
    }
    ....
  }
  else
  {
    ....
    if (window != null)
    {
      window.ClientSize = new Size2(clientWidth, clientHeight);
      window.Location = savedFormLocation;
      ....
      window.BringToFront();
    }

  }
  ....
}

WPF samples by Microsoft

V3095 The 'htmlLiElement' object was used before it was verified against null. Check lines: 916, 936. HtmlToXamlConverter.cs 916


private static XmlElement AddOrphanListItems(....)
{
  Debug.Assert(htmlLiElement.LocalName.ToLower() == "li");
  ....
  XmlNode htmlChildNode = htmlLiElement;
  var htmlChildNodeName = htmlChildNode == null
      ? null
      : htmlChildNode.LocalName.ToLower();
  ....
}

Old NASA World Wind (C#)

V3095 The 'this.linePoints' object was used before it was verified against null. Check lines: 332, 346. PathLine.cs 332


public override void Render(DrawArgs drawArgs)
{
  ....
  if(this.linePoints.Length > 1)    // <=
  {
    ....
    if(this.linePoints != null)     // <=
    {
      ....
    }
  }
  ....
}

Also see V3022


FlashDevelop

V3095 The 'node' object was used before it was verified against null. Check lines: 364, 365. ProjectContextMenu.cs 364


private void AddFolderItems(MergableMenu menu, string path)
{
  ....
  DirectoryNode node = projectTree.SelectedNode
    as DirectoryNode;
  if (node.InsideClasspath == node)
    menu.Add(RemoveSourcePath, 2, true);
  else if (node != null && ....)
  {
    menu.Add(AddSourcePath, 2, false);
  }
  ....
}

Unity3D

V3095 The 'uv2.gameObject' object was used before it was verified against null. Check lines: 1719, 1731. UnityEngine.Networking NetworkServer.cs 1719


static public bool SpawnObjects()
{
  ....
  if (uv2.gameObject.hideFlags == HideFlags.NotEditable ||
      uv2.gameObject.hideFlags == HideFlags.HideAndDontSave)
    continue;
  ....
  if (uv2.gameObject == null)
    continue;
  ....
}

Similar errors can be found in some other places:

  • V3095 The 'm_HorizontalScrollbarRect' object was used before it was verified against null. Check lines: 214, 220. UnityEngine.UI ScrollRect.cs 214
  • V3095 The 'm_VerticalScrollbarRect' object was used before it was verified against null. Check lines: 215, 221. UnityEngine.UI ScrollRect.cs 215

MSBuild

V3095 The 'diskRoots' object was used before it was verified against null. Check lines: 2656, 2659. ToolLocationHelper.cs 2656


private static void ExtractSdkDiskRootsFromEnvironment
(List<string> diskRoots, string directoryRoots)
{
  if (!String.IsNullOrEmpty(directoryRoots))
  {
    ....
    diskRoots.AddRange(splitRoots);  // <=
  }

  if (diskRoots != null)             // <=
  ....
}

Similar errors can be found in some other places:

  • V3095 The 'propertyValue' object was used before it was verified against null. Check lines: 2760, 2799. Expander.cs 2760
  • V3095 The 'publicKeyToken' object was used before it was verified against null. Check lines: 232, 236. GenerateBindingRedirects.cs 231
  • V3095 The 'searchLocation' object was used before it was verified against null. Check lines: 170, 178. Resolver.cs 170
  • And 7 additional diagnostic messages.

GitExtensions

V3095 The 'data' object was used before it was verified against null. Check lines: 319, 376. GitCommands RevisionGraph.cs 319


void DataReceived(string data)
{
  if (data.StartsWith(CommitBegin)) // <=
  {
      ....
  }

  if (!string.IsNullOrEmpty(data))
  {
      ....
  }
}

Similar errors can be found in some other places:

  • V3095 The 'line' object was used before it was verified against null. Check lines: 1979, 1981. GitCommands GitModule.cs 1979
  • V3095 The 'head' object was used before it was verified against null. Check lines: 2414, 2422. GitCommands GitModule.cs 2414

PowerShell

V3095 The 'inputParameters' object was used before it was verified against null. Check lines: 430, 436. System.Management.Automation FormatViewGenerator_Complex.cs 430


internal ComplexViewEntry
  GenerateView(....,
               FormattingCommandLineParameters inputParameters)
{
  _complexSpecificParameters =
    (ComplexSpecificParameters)inputParameters.shapeParameters;

  int maxDepth = _complexSpecificParameters.maxDepth;
  ....
  if (inputParameters != null)
    mshParameterList = inputParameters.mshParameterList;
  ....
}

PowerShell

V3095 The 'other.Parameters' object was used before it was verified against null. Check lines: 189, 192. System.Management.Automation CommandMetadata.cs 189


public CommandMetadata(CommandMetadata other)
{
  ....
  _parameters = new Dictionary<string, ParameterMetadata>(
    other.Parameters.Count, StringComparer.OrdinalIgnoreCase);

  // deep copy
  if (other.Parameters != null)
  ....
}

Orchard CMS

V3095 The 'Delegate' object was used before it was verified against null. Check lines: 37, 40. SerializableDelegate.cs 37


void ISerializable.GetObjectData(
  SerializationInfo info,
  StreamingContext context)
{
  info.AddValue("delegateType", Delegate.GetType());
  ....
  if (.... && Delegate != null)
  {
    ....
  }
}

Similar errors can be found in some other places:

  • V3095 The 'widget' object was used before it was verified against null. Check lines: 81, 93. TagsWidgetCommands.cs 81

Umbraco

V3095 The 'dataset' object was used before it was verified against null. Check lines: 48, 49. ImageCropperBaseExtensions.cs 48


internal static ImageCropData GetCrop(....)
{
  var imageCropDatas = dataset.ToArray();
  if (dataset == null || imageCropDatas.Any() == false)
    return null;
  ....
}

Similar errors can be found in some other places:

  • V3095 The 'display.PropertyEditor' object was used before it was verified against null. Check lines: 30, 43. ContentPropertyDisplayConverter.cs 30
  • V3095 The 'typedSource' object was used before it was verified against null. Check lines: 164, 198. DynamicQueryable.cs 164
  • V3095 The 'attempt.Result' object was used before it was verified against null. Check lines: 90, 113. DynamicPublishedContent.cs 90
  • And 8 additional diagnostic messages.

SharpDevelop

V3095 The 'position' object was used before it was verified against null. Check lines: 204, 206. Task.cs 204


public void JumpToPosition()
{
  if (hasLocation && !position.IsDeleted)
    ....
  else if (position != null)
    ....
}

Media Portal 2

V3095 The 'result' object was used before it was verified against null. Check lines: 1292, 1294. VideoMetadataExtractor.cs 1292


public bool TryExtractMetadata(....)
{
  using (Stream stream = fsra.OpenRead())
    result.MimeType = MimeTypeDetector.GetMimeType(
      stream, DEFAULT_MIMETYPE);

  if (result != null)                         // <=
  {
    ....
  }
}

Similar errors can be found in some other places:

  • V3095 The '_type' object was used before it was verified against null. Check lines: 104, 106. AbstractProperty.cs 104
  • V3095 The 'seasonDetail' object was used before it was verified against null. Check lines: 360, 361. OmDbWrapper.cs 360

PascalABC.NET

V3095 The 'VisualEnvironmentCompiler.RemoteCompiler' object was used before it was verified against null. Check lines: 52, 54. CompilerController CompilerControllerPlugin.cs 52


public CompilerController_VisualPascalABCPlugin(....)
{
  ....
  VisualEnvironmentCompiler.RemoteCompiler.InternalDebug.
    RunOnMono = CompilerInformation.cbRunMono.Checked;
  ....
  if (VisualEnvironmentCompiler.RemoteCompiler != null)
    ....
}

Similar errors can be found in some other places:

  • V3095 The 'cun' object was used before it was verified against null. Check lines: 400, 401. Compiler PCUReader.cs 400
  • V3095 The 'cnfn.ConnectedToType.element_type' object was used before it was verified against null. Check lines: 2918, 2930. Compiler PCUReader.cs 2918
  • V3095 The '_currentTreeNode' object was used before it was verified against null. Check lines: 590, 593. TreeConverter CapturedVariablesTreeBuilder.cs 590
  • And 7 additional diagnostic messages.

Unity C# reference source code

V3095 CWE-476 The 'element' object was used before it was verified against null. Check lines: 101, 107. StyleContext.cs 101


public override void
OnBeginElementTest(VisualElement element, ....)
{
  if (element.IsDirty(ChangeType.Styles))
  {
    ....
  }

  if (element != null && element.styleSheets != null)
  {
    ....
  }
  ....
}

Similar errors can be found in some other places:

  • V3095 CWE-476 The 'property' object was used before it was verified against null. Check lines: 5137, 5154. EditorGUI.cs 5137
  • V3095 CWE-476 The 'exposedPropertyTable' object was used before it was verified against null. Check lines: 152, 154. ExposedReferenceDrawer.cs 152
  • V3095 CWE-476 The 'rectObjs' object was used before it was verified against null. Check lines: 97, 99. RectSelection.cs 97
  • And 7 additional diagnostic messages.

Infer.NET

V3095 The 'quantiles' object was used before it was verified against null. Check lines: 91, 92. Runtime OuterQuantiles.cs 91


public static double GetQuantile(double probability,
                                 double[] quantiles)
{
  ....
  int n = quantiles.Length;
  if (quantiles == null)
    throw new ArgumentNullException(nameof(quantiles));
  if (n == 0)
    throw new ArgumentException("quantiles array is empty", nameof(quantiles));
  ....
}

AWS SDK for .NET

V3095 [CWE-476] The 'conditionValues' object was used before it was verified against null. Check lines: 228, 238. AWSSDK.Core.Net45 JsonPolicyWriter.cs 228


private static void writeConditions(....)
{
  ....
  foreach (....)
  {
    IList<string> conditionValues = keyEntry.Value;
    if (conditionValues.Count == 0) // <=
      continue;
    ....
    if (conditionValues != null && conditionValues.Count != 0)
    {
      ....
    }
    ....
  }
}

Similar errors can be found in some other places:

  • V3095 [CWE-476] The 'ts.Listeners' object was used before it was verified against null. Check lines: 140, 143. AWSSDK.Core.Net45 Logger.Diagnostic.cs 140
  • V3095 [CWE-476] The 'obj' object was used before it was verified against null. Check lines: 743, 745. AWSSDK.Core.Net45 JsonMapper.cs 743
  • V3095 [CWE-476] The 'multipartUploadMultipartUploadpartsList' object was used before it was verified against null. Check lines: 65, 67. AWSSDK.S3.Net45 CompleteMultipartUploadRequestMarshaller.cs 65

.NET Core Libraries (CoreFX)

V3095 The 'context' object was used before it was verified against null. Check lines: 340, 346. Principal.cs 340


abstract public class Principal : IDisposable
{
  ....
  public void Save(PrincipalContext context)
  {
    ....

    if (   context.ContextType == ContextType.Machine  // <=
        || _ctx.ContextType == ContextType.Machine)
    {
      throw new InvalidOperationException(
        SR.SaveToNotSupportedAgainstMachineStore);
    }

    if (context == null)                               // <=
    {
      Debug.Assert(this.unpersisted == true);
      throw new InvalidOperationException(SR.NullArguments);
    }
    ....
  }
  ....
}

.NET Core Libraries (CoreFX)

V3095 The 'propertyNames' object was used before it was verified against null. Check lines: 990, 1004. DirectoryEntry.cs 990


public class DirectoryEntry : Component
{
  ....
  public void RefreshCache(string[] propertyNames)
  {
    ....
    object[] names = new object[propertyNames.Length];         // <=
    for (int i = 0; i < propertyNames.Length; i++)
      names[i] = propertyNames[i];
    ....
    if (_propertyCollection != null && propertyNames != null)  // <=
      ....
    ....
  }
  ....
}

.NET Core Libraries (CoreFX)

V3095 The 'outputStream' object was used before it was verified against null. Check lines: 654, 672. Icon.Windows.cs 654


public sealed partial class Icon :
  MarshalByRefObject, ICloneable, IDisposable, ISerializable
{
  ....
  public void Save(Stream outputStream)
  {
    if (_iconData != null)
    {
      outputStream.Write(_iconData, 0, _iconData.Length); // <=
    }
    else
    {
      ....
      if (outputStream == null)                           // <=
        throw new ArgumentNullException("dataStream");
      ....
    }
  }
  ....
}

.NET Core Libraries (CoreFX)

V3095 The 'seq' object was used before it was verified against null. Check lines: 880, 884. XmlQueryRuntime.cs 880


public IList<XPathNavigator> DocOrderDistinct(IList<XPathNavigator> seq)
{
  if (seq.Count <= 1) // <=
    return seq;

  XmlQueryNodeSequence nodeSeq = (XmlQueryNodeSequence)seq; // <=
  if (nodeSeq == null) // <=
    nodeSeq = new XmlQueryNodeSequence(seq);

  return nodeSeq.DocOrderDistinct(_docOrderCmp);
}

.NET Core Libraries (CoreFX)

V3095 The 'other' object was used before it was verified against null. Check lines: 1095, 1096. XPathNodePointer.cs 1095


internal XmlNodeOrder ComparePosition(XPathNodePointer other)
{
  RealFoliate();
  other.RealFoliate();
  Debug.Assert(other != null);
  ....
}

.NET Core Libraries (CoreFX)

V3095 The 'buffer' object was used before it was verified against null. Check lines: 51, 53. HttpRequestStream.cs 51


public override IAsyncResult BeginRead(byte[] buffer, ....)
{
  if (NetEventSource.IsEnabled)
  {
    NetEventSource.Enter(this);
    NetEventSource.Info(this,
                        "buffer.Length:" + buffer.Length +  // <=
                        " size:" + size +
                        " offset:" + offset);
  }
  if (buffer == null) // <=
  {
    throw new ArgumentNullException(nameof(buffer));
  }
  ....
}

Similar errors can be found in some other places:

  • V3095 The 'buffer' object was used before it was verified against null. Check lines: 49, 51. HttpResponseStream.cs 49
  • V3095 The 'buffer' object was used before it was verified against null. Check lines: 74, 75. HttpResponseStream.cs 74

.NET Core Libraries (CoreFX)

V3095 The 'tx' object was used before it was verified against null. Check lines: 3282, 3285. TransactionState.cs 3282


internal override void EnterState(InternalTransaction tx)
{
  if (tx._outcomeSource._isoLevel == IsolationLevel.Snapshot) // <=
  {
    throw TransactionException.CreateInvalidOperationException(
            ....,
            tx == null ? Guid.Empty : tx.DistributedTxId);   // <=
  }
  ....
}

Roslyn Analyzers

V3095 The 'rule' object was used before it was verified against null. Check lines: 2180, 2181. CodeFixProvider.cs 2180


internal static string GetFirstRuleName(ClassDeclarationSyntax declaration)
{
  SyntaxList<MemberDeclarationSyntax> members = declaration.Members;
  FieldDeclarationSyntax rule = null;

  foreach (MemberDeclarationSyntax member in members)
  {
     rule = member as FieldDeclarationSyntax;
     var ruleType = rule.Declaration.Type as IdentifierNameSyntax;
     if (rule != null
         && ruleType != null
         && ruleType.Identifier.Text == "DiagnosticDescriptor")
       {break;}
     rule = null;
  }
  ....
}

ShareX

V3095 [CWE-476] The 'pi' object was used before it was verified against null. Check lines: 801, 803. ImageHelpers.cs 801


public static bool AddMetadata(Image img, int id, string text)
{
  ....
  pi.Value = bytesText; // <=

  if (pi != null)
  {
    img.SetPropertyItem(pi);
    return true;
  }
  ....
}

ShareX

V3095 [CWE-476] The 'task' object was used before it was verified against null. Check lines: 268, 270. TaskManager.cs 268


private static void Task_TaskCompleted(WorkerTask task)
{
  ....
  task.KeepImage = false; // <=

  if (task != null)
  {
    if (task.RequestSettingUpdate)
    {
      Program.MainForm.UpdateCheckStates();
    }
    ....
  }
  ....
}

Similar errors can be found in some other places:

  • V3095 [CWE-476] The 'Config.PhotobucketAccountInfo' object was used before it was verified against null. Check lines: 216, 219. UploadersConfigForm.cs 216

Azure PowerShell

V3095 The 'certificate' object was used before it was verified against null. Check lines: 41, 43. CertificateInfo.cs 41


public CertificateInfo(
  ....,
  Azure.Management.Automation.Models.Certificate certificate)
{
  ....
  this.Name = certificate.Name;

  if (certificate == null) return;
  ....
}

Similar errors can be found in some other places:

  • V3095 The 'clusterCred' object was used before it was verified against null. Check lines: 115, 118. InvokeHiveCommand.cs 115
  • V3095 The '_profile' object was used before it was verified against null. Check lines: 47, 49. RMProfileClient.cs 47
  • V3095 The 'this.LoadBalancer.BackendAddressPools' object was used before it was verified against null. Check lines: 56, 63. AddAzureRmLoadBalancerBackendAddressPoolConfigCommand.cs 56

Orchard CMS

V3095 The 'remoteClient' object was used before it was verified against null. Check lines: 49, 51. ImportRemoteInstanceController.cs 49


public async Task<IActionResult> Import(ImportViewModel model)
{
  ....
  var remoteClient = remoteClientList.RemoteClients.FirstOrDefault(....);
  var apiKey = Encoding.UTF8.GetString(....(remoteClient.ProtectedApiKey));
  if (remoteClient == null || ....)
  {
    ....
  }
  ....
}

Azure SDK for .NET

V3095 The 'httpRequest.Content.Headers' object was used before it was verified against null. Check lines: 76, 79. BatchSharedKeyCredential.cs 76


public override Task ProcessHttpRequestAsync(
  HttpRequestMessage httpRequest, ....)
{
  ....
  signature.Append(httpRequest.Content != null
    && httpRequest.Content.Headers.Contains("Content-Language") ? .... : ....;

  long? contentLength = httpRequest.Content?.Headers?.ContentLength;
  ....
}

osu!

V3095 [CWE-476] The 'columns' object was used before it was verified against null. Check lines: 141, 142. SquareGraph.cs 141


private void redrawProgress()
{
  for (int i = 0; i < ColumnCount; i++)
    columns[i].State = i <= progress ? ColumnState.Lit : ColumnState.Dimmed;
  columns?.ForceRedraw();
}

Chocolatey

V3095 [CWE-476] The 'installedPackage' object was used before it was verified against null. Check lines: 910, 917. NugetService.cs 910


public virtual ConcurrentDictionary<string, PackageResult> get_outdated(....)
{
  ....
  var pinnedPackageResult = outdatedPackages.GetOrAdd(
    packageName,
    new PackageResult(installedPackage,
                      _fileSystem.combine_paths(
                        ApplicationParameters.PackagesLocation,
                        installedPackage.Id)));
  ....
  if (   installedPackage != null
      && !string.IsNullOrWhiteSpace(installedPackage.Version.SpecialVersion)
      && !config.UpgradeCommand.ExcludePrerelease)
  {
    ....
  }
  ....
}

Nethermind

V3095 The '_logger' object was used before it was verified against null. Check lines: 118, 118. Nethermind.Wallet DevKeyStoreWallet.cs 118


public void Sign(Transaction tx, int chainId)
{
  if (_logger.IsDebug)
    _logger?.Debug($"Signing transaction: {tx.Value} to {tx.To}");
  IBasicWallet.Sign(this, tx, chainId);
}

Similar errors can be found in some other places:

  • V3095 The '_enode' object was used before it was verified against null. Check lines: 55, 56. Nethermind.JsonRpc AdminModule.cs 55

RavenDB

V3095 The 'node.Indexer' object was used before it was verified against null. Check lines: 1180, 1182. ExpressionStringBuilder.cs(1180), ExpressionStringBuilder.cs(1182) Raven.Client


protected override Expression VisitIndex(IndexExpression node)
{
  if (node.Object != null)
  {
    Visit(node.Object);
  }
  else
  {
    Out(node.Indexer.DeclaringType.Name); // <=
  }
  if (node.Indexer != null)               // <=
  {
    Out(".");
    Out(node.Indexer.Name);
  }
  VisitExpressions('[', node.Arguments, ']');
  return node;
}

ONLYOFFICE Community Server

V3095 The 'r.Attributes["href"]' object was used before it was verified against null. Check lines: 86, 87. HelpCenterStorage.cs 86


public override void Init(string html, string helpLinkBlock, string baseUrl)
{
    ....
    foreach (var href in hrefs.Where(r =>
    {
        var value = r.Attributes["href"].Value;
        return r.Attributes["href"] != null
               && !string.IsNullOrEmpty(value)
               && !value.StartsWith("mailto:")
               && !value.StartsWith("http");
    }))
    {
      ....
    }
    ....
}

ILSpy

V3095 The 'roslynProject' object was used before it was verified against null. Check lines: 96, 97. ILSpy.AddIn OpenILSpyCommand.cs 96


protected Dictionary<string, DetectedReference> GetReferences(....)
{
  ....
  var roslynProject =  owner.Workspace
                            .CurrentSolution
                            .GetProject(projectReference.ProjectId);
  var project = FindProject(owner.DTE.Solution
                                 .Projects.OfType<EnvDTE.Project>(),
                            roslynProject.FilePath);              // <=

  if (roslynProject != null && project != null)                   // <=
  ....
}

ILSpy

V3095 The 'listBox' object was used before it was verified against null. Check lines: 46, 52. ILSpy FlagsFilterControl.xaml.cs 46


public override void OnApplyTemplate()
{
  base.OnApplyTemplate();

  listBox = Template.FindName("ListBox", this) as ListBox;
  listBox.ItemsSource = FlagGroup.GetFlags(....);         // <=

  var filter = Filter;

  if (filter == null || filter.Mask == -1)
  {
    listBox?.SelectAll();                                 // <=
  }
}

Similar errors can be found in some other places:

  • V3095 The 'pV' object was used before it was verified against null. Check lines: 761, 765. ICSharpCode.Decompiler TypeInference.cs 761
  • V3095 The 'pU' object was used before it was verified against null. Check lines: 882, 886. ICSharpCode.Decompiler TypeInference.cs 882
  • V3095 The 'finalStore' object was used before it was verified against null. Check lines: 261, 262. ICSharpCode.Decompiler TransformArrayInitializers.cs 261
  • And 5 additional diagnostic messages.

Ryujinx

V3095 The 'firmwareVersion' object was used before it was verified against null. Check lines: 1157, 1159. MainWindow.cs 1157


private void HandleInstallerDialog(FileChooserDialog fileChooser){
    ....

    string dialogTitle = $"Install Firmware {firmwareVersion.VersionString}";

     if (firmwareVersion == null)
    {
        ....
    }
    ....
}

Similar errors can be found in some other places:

  • V3095 The '_profileEntry.Text' object was used before it was verified against null. Check lines: 34, 40. ProfileDialog.cs 34
  • V3095 The 'Owner' object was used before it was verified against null. Check lines: 1084, 1103. KThread.cs 1084
  • V3095 The '_nsdSettings' object was used before it was verified against null. Check lines: 44, 48. FqdnResolver.cs 44
  • And 3 additional diagnostic messages.

DotNetNuke

V3095 The 'settings' object was used before it was verified against null. Check lines: 190, 195. NavigationManager.cs 190


public string NavigateURL(int tabID,
                          bool isSuperTab,
                          IPortalSettings settings,
                          ....)
{
  ....
  if (isSuperTab)
  {
    url += "&portalid=" + settings.PortalId;
  }

  TabInfo tab = null;
  if (settings != null)
  {
    tab = TabController.Instance.GetTab(tabID,
            isSuperTab ? Null.NullInteger : settings.PortalId, false);
  }
  ....
}

DotNetNuke

V3095 The 'coloumnValue' object was used before it was verified against null. Check lines: 902, 903. CBO.cs 902


private static void HydrateObject(object hydratedObject, IDataReader dr)
{
  ....
  // Get the Data Value's type
  objDataType = coloumnValue.GetType();
  if (coloumnValue == null || coloumnValue == DBNull.Value)
  {
    // set property value to Null
    objPropertyInfo.SetValue(hydratedObject,
                             Null.SetNull(objPropertyInfo),
                             null);
  }
  ....
}

DotNetNuke

V3095 The 'tempLanguagePack' object was used before it was verified against null. Check lines: 235, 236. LanguageInstaller.cs 235


private void DeleteLanguage()
{
  ....
  // Attempt to get the Locale
  Locale language = LocaleController.Instance
                                    .GetLocale(tempLanguagePack.LanguageID);
  if (tempLanguagePack != null)
  {
    LanguagePackController.DeleteLanguagePack(tempLanguagePack);
  }
  ....
}

DotNetNuke

V3095 The 'portalAliasses' object was used before it was verified against null. Check lines: 1834, 1835. Localization.cs 1834


private static void AddLanguageHttpAlias(int portalId, Locale locale)
{
  ....
  var portalAliasInfos =    portalAliasses as IList<PortalAliasInfo>
                         ?? portalAliasses.ToList();

  if (portalAliasses != null && portalAliasInfos.Any())
  ....
}

DotNetNuke

V3095 The 'e.FullPath' object was used before it was verified against null. Check lines: 147, 152. DotNetNukeShutdownOverload.cs 147


private static void WatcherOnChanged(object sender, FileSystemEventArgs e)
{
  if (Logger.IsInfoEnabled && !e.FullPath.EndsWith(".log.resources"))     // <=
  {
    Logger.Info($"Watcher Activity: {e.ChangeType}. Path: {e.FullPath}");
  }

  if (   _handleShutdowns
      && !_shutdownInprogress
      && (e.FullPath ?? string.Empty)                                     // <=
            .StartsWith(_binFolder,
                        StringComparison.InvariantCultureIgnoreCase))
  {
    ShceduleShutdown();
  }
}

Similar errors can be found in some other places:

  • V3095 The 'e.FullPath' object was used before it was verified against null. Check lines: 160, 165. DotNetNukeShutdownOverload.cs 160
  • V3095 The 'e.FullPath' object was used before it was verified against null. Check lines: 173, 178. DotNetNukeShutdownOverload.cs 173
  • V3095 The 'e.FullPath' object was used before it was verified against null. Check lines: 186, 191. DotNetNukeShutdownOverload.cs 186

DotNetNuke

V3095 The 'tabIds' object was used before it was verified against null. Check lines: 356, 357. TabsController.cs 356


private IEnumerable<TabDto> GetDescendantsForTabs(
  IEnumerable<int> tabIds,
  IEnumerable<TabDto> tabs,
  int selectedTabId,
  int portalId,
  string cultureCode,
  bool isMultiLanguage)
{
  var enumerable = tabIds as int[] ?? tabIds.ToArray();
  if (tabs == null || tabIds == null || !enumerable.Any())
  {
    return tabs;
  }
  ....
}

Eto.Forms

V3095 The 'Widget.Binding' object was used before it was verified against null. Check lines: 42, 43. Eto.Mac64 ProgressCellHandler.cs 42


public override NSObject GetObjectValue(object dataItem)
{
  float? progress = Widget.Binding.GetValue(dataItem);  // <=
  if (Widget.Binding != null && progress.HasValue)      // <=
  {
    progress = progress < 0f ? 0f : progress > 1f ? 1f : progress;
    return new NSNumber((float)progress);
  }
  return new NSNumber(float.NaN);
}

Barotrauma

V3095 The 'level' object was used before it was verified against null. Check lines: 107, 115. BeaconMission.cs 107


public override void End()
{
  completed = level.CheckBeaconActive();                        // <=
  if (completed)
  {
    if (Prefab.LocationTypeChangeOnCompleted != null)
    {
      ChangeLocationType(Prefab.LocationTypeChangeOnCompleted);
    }
    GiveReward();
    if (level?.LevelData != null)                               // <=
    {
      level.LevelData.IsBeaconActive = true;
    }
  }
}

Bitwarden

V3095 The 'userId' object was used before it was verified against null. Check lines: 640, 683. CipherService.cs 640


public async Task ImportCiphersAsync(
  List<Folder> folders,
  List<CipherDetails> ciphers,
  IEnumerable<KeyValuePair<int, int>> folderRelationships)
{
  var userId = folders.FirstOrDefault()?.UserId ??
               ciphers.FirstOrDefault()?.UserId;

  var personalOwnershipPolicyCount =
    await _policyRepository
          .GetCountByTypeApplicableToUserIdAsync(userId.Value, ....);
  ....
  if (userId.HasValue)
  {
    await _pushService.PushSyncVaultAsync(userId.Value);
  }
}

Bitwarden

V3095 The 'pageOptions' object was used before it was verified against null. Check lines: 135, 137. EventRepository.cs 135


public async Task<PagedResult<IEvent>> GetManyAsync(
  ....,
  PageOptions pageOptions)
{
  ....
  var query = new TableQuery<EventTableEntity>()
                  .Where(filter)
                  .Take(pageOptions.PageSize);                        // <=
  var result = new PagedResult<IEvent>();
  var continuationToken = DeserializeContinuationToken(
                            pageOptions?.ContinuationToken);          // <=
  ....
}

Bitwarden

V3095 The 'x.u' object was used before it was verified against null. Check lines: 24, 32. OrganizationUserUserViewQuery.cs 24


public IQueryable<OrganizationUserUserDetails> Run(DatabaseContext dbContext)
{
  ....
  return query.Select(x => new OrganizationUserUserDetails
  {
    Id = x.ou.Id,
    OrganizationId = x.ou.OrganizationId,
    UserId = x.ou.UserId,
    Name = x.u.Name,                                             // <=
    Email = x.u.Email ?? x.ou.Email,                             // <=
    TwoFactorProviders = x.u.TwoFactorProviders,                 // <=
    Premium = x.u.Premium,                                       // <=
    Status = x.ou.Status,
    Type = x.ou.Type,
    AccessAll = x.ou.AccessAll,
    ExternalId = x.ou.ExternalId,
    SsoExternalId = x.su.ExternalId,
    Permissions = x.ou.Permissions,
    ResetPasswordKey = x.ou.ResetPasswordKey,
    UsesKeyConnector = x.u != null && x.u.UsesKeyConnector,      // <=
  });
}

Bitwarden

V3095 The 'organization' object was used before it was verified against null. Check lines: 1085, 1086. OrganizationService.cs 1085


public async Task<List<OrganizationUser>> InviteUsersAsync(
  Guid organizationId,
  Guid? invitingUserId,
  IEnumerable<(OrganizationUserInvite invite, string externalId)> invites)
{
  var organization = await GetOrgById(organizationId);
  var initialSeatCount = organization.Seats;
  if (organization == null || invites.Any(i => i.invite.Emails == null))
  {
    throw new NotFoundException();
  }
  ....
}

Orleans

V3095 The 'participant' object was used before it was verified against null. Check lines: 282, 284. LocalSiloHealthMonitor.cs 282


private int CheckLocalHealthCheckParticipants(DateTime now,
                                              List<string> complaints)
{
  var score = 0;
  foreach (var participant in _healthCheckParticipants)
  {
    try
    {
      if (!participant.CheckHealth(_lastHealthCheckTime, out var reason))  // <=
      {
        _log.LogWarning(...., participant?.GetType().ToString(), reason);  // <=
        complaints?.Add($".... {participant?.GetType().ToString()} ...."); // <=
        ++score;
      }
    }
    catch (Exception exception)
    {
      _log.LogError(exception, ...., participant?.GetType().ToString());   // <=
      Complaints?.Add($".... {participant?.GetType().ToString()} ....");   // <=
      ++score;
    }
  }

  _lastHealthCheckTime = now;
  return score;
}

AvalonStudio

V3095 The 'loadData' object was used before it was verified against null. Check lines: 233, 262. MSBuildHost.cs 233


public async Task<(....)> LoadProject(....)
{
  ....
  return await Task.Run(() =>
  {
    ....
    if (   loadData.CscCommandLine != null                            // <=
        && loadData.CscCommandLine.Count > 0)
    {
      ....
      return (projectInfo, projectReferences, loadData.TargetPath);
    }
    else
    {
      ....
      return (projectInfo, projectReferences, loadData?.TargetPath);  // <=
    }
  });
}

Discord.NET

V3095 The 'guild' object was used before it was verified against null. Check lines: 76, 88. SocketResolvableData.cs 76


internal SocketResolvableData(DiscordSocketClient discord,
                              ulong? guildId,
                              T model)
{
  var guild = guildId.HasValue ? discord.GetGuild(guildId.Value) : null;
  ....
  if (resolved.Members.IsSpecified && guild != null)         // <=
  {
    ....
    var user = guild.AddOrUpdateUser(member.Value);
    ....
  }

  if (resolved.Roles.IsSpecified)
  {
    foreach (var role in resolved.Roles.Value)
    {
      var socketRole = guild.AddOrUpdateRole(role.Value);    // <=
      ....
    }
  }

  if (resolved.Messages.IsSpecified)
  {
    foreach (var msg in resolved.Messages.Value)
    {
      ....
      if (guild != null)                                     // <=
      {
        if (msg.Value.WebhookId.IsSpecified)
          ....
        else
          author = guild.GetUser(msg.Value.Author.Value.Id);
      }
      else
        ....
    }
  }
  ....
}

Discord.NET

V3095 The 'model.Roles' object was used before it was verified against null. Check lines: 534, 535. SocketGuild.cs 534


internal void Update(ClientState state, Model model)
{
  var roles =
       new ConcurrentDictionary<ulong, SocketRole>
           (ConcurrentHashSet.DefaultConcurrencyLevel,
           (int)(model.Roles.Length * 1.05));         // <=
  if (model.Roles != null)                            // <=
  {
    for (int i = 0; i < model.Roles.Length; i++)
    {
      var role = SocketRole.Create(this, state, model.Roles[i]);
      roles.TryAdd(role.Id, role);
    }
  }
}

OrchardCore

V3095 The 'info' object was used before it was verified against null. Check lines: 637, 641. AccountController.cs 637


public async Task<IActionResult> LinkExternalLogin(
                   LinkExternalLoginViewModel model,
                   string returnUrl = null)
{
  ....
  var info = await _signInManager.GetExternalLoginInfoAsync();

  var email = info.Principal.FindFirstValue(ClaimTypes.Email)
           ?? info.Principal.FindFirstValue("email");
  ....

  if (info == null)
  {
    _logger.LogWarning("Error loading external login info.");
    return NotFound();
  }
  ....
}

OrchardCore

V3095 The 'paths' object was used before it was verified against null. Check lines: 304, 312. AdminController.cs 304


public async Task<IActionResult> DeleteMediaList(string[] paths)
{
  foreach (var path in paths)
  {
    ....
  }

  if (paths == null)
  {
    return NotFound();
  }
  ....
}

OrchardCore

V3095 The 'newVersion' object was used before it was verified against null. Check lines: 94, 95. BlogPostCreateDeploymentPlanTests.cs 94


public async Task ShouldDiscardDraftThenCreateNewPublishedContentItemVersion()
{
  using (var context = new BlogPostDeploymentContext())
  {
    ....
    await shellScope.UsingAsync(async scope =>
    {
      ....
      var originalVersion = blogPosts.FirstOrDefault(x =>
           x.ContentItemVersionId == context.OriginalBlogPostVersionId);
      Assert.False(originalVersion?.Latest);
      Assert.False(originalVersion?.Published);

      var draftVersion = blogPosts.FirstOrDefault(x =>
           x.ContentItemVersionId == draftContentItemVersionId);
      Assert.False(draftVersion?.Latest);
      Assert.False(draftVersion?.Published);

      var newVersion = blogPosts.FirstOrDefault(x =>
           x.ContentItemVersionId == "newversion");
      Assert.Equal("new version", newVersion.DisplayText);           // <=
      Assert.True(newVersion?.Latest);                               // <=
      Assert.True(newVersion?.Published);                            // <=
    });
  }
}

.NET MAUI

V3095 The 'bo' object was used before it was verified against null. Check lines: 44, 45. FormattedString.cs 44


void OnCollectionChanged(....)
{
  ....
    foreach (object item in e.OldItems)
    {
      var bo = item as Span;
      bo.Parent = null;                   // <=
      if (bo != null)
      {
        ....
      }
  ....
}

protobuf-net

V3095 The 'definition' object was used before it was verified against null. Check lines: 139, 141. NameNormalizer.cs 139


public virtual string GetName(FileDescriptorProto definition)
{
  var ns = definition?.Options?.GetOptions()?.Namespace;
  if (!string.IsNullOrWhiteSpace(ns)) return ns;
  ns = definition.Options?.CsharpNamespace;
  if (string.IsNullOrWhiteSpace(ns)) ns = GetName(definition.Package); // <=

  if (string.IsNullOrEmpty(ns)) ns = definition?.DefaultPackage;       // <=

  return string.IsNullOrWhiteSpace(ns) ? null : ns;
}

protobuf-net

V3095 The 'enumType' object was used before it was verified against null. Check lines: 13, 14. EnumMemberSerializer.cs 13


public EnumMemberSerializer(Type enumType)
{
  if (!enumType.IsEnum)                                                   // <=
    ThrowHelper.ThrowInvalidOperationException("...." +
                                               enumType.NormalizeName());
  ExpectedType = enumType ??                                              // <=
                 throw new ArgumentNullException(nameof(enumType));
  _tail = Type.GetTypeCode(enumType) switch
  {
    ....
  };
  if (_tail is null)
    ThrowHelper.ThrowInvalidOperationException("...." +
                                               enumType.NormalizeName());
}

.NET 7

V3095 The '_callbacks' object was used before it was verified against null. Check lines: 22, 30. PipeCompletionCallbacks.cs 22


public void Execute()
{
  var count = _callbacks.Count;       // <=
  if (count == 0)
  {
    return;
  }

  List<Exception>? exceptions = null;

  if (_callbacks != null)             // <=
  {
    for (int i = 0; i < count; i++)
    {
      var callback = _callbacks[i];
      Execute(callback, ref exceptions);
    }
  }

  if (exceptions != null)
  {
    throw new AggregateException(exceptions);
  }
}

.NET 7

V3095 The 'pOperand1' object was used before it was verified against null. Check lines: 798, 800. ExpressionBinder.cs 798


private static RuntimeBinderException BadOperatorTypesError(Expr pOperand1,
                                                            Expr pOperand2)
{
  // ....
  string strOp = pOperand1.ErrorString;  // <=

  Debug.Assert(pOperand1 != null);       // <=
  Debug.Assert(pOperand1.Type != null);

  if (pOperand2 != null)
  {
    Debug.Assert(pOperand2.Type != null);
    return ErrorHandling.Error(ErrorCode.ERR_BadBinaryOps,
                               strOp,
                               pOperand1.Type,
                               pOperand2.Type);
  }

  return ErrorHandling.Error(ErrorCode.ERR_BadUnaryOp, strOp, pOperand1.Type);
}

BTCPay Server

V3095 The 'request' object was used before it was verified against null. Check lines: 355, 364. BTCPayServer\Controllers\GreenField\GreenfieldPullPaymentController.cs 355


public async Task<IActionResult> CreatePayoutThroughStore(....)
{
    if (request.Approved is true)
    {
        if (!(await _authorizationService.AuthorizeAsync(....)).Succeeded)
        {
            return this.CreateAPIPermissionError(....);
        }
    }

    if (request is null ||
        !PaymentMethodId.TryParse(request?.PaymentMethod, ....))
    {
        ModelState.AddModelError(nameof(request.PaymentMethod),
            "Invalid payment method");
        return this.CreateValidationError(ModelState);
    }
    ....
}

AWS SDK for .NET

V3095 The 'endpoint' object was used before it was verified against null. Check lines: 111, 118. AmazonS3Client.Extensions.cs 111


internal string
GetPreSignedURLInternal(....)
{
  ....
  RegionEndpoint endpoint = RegionEndpoint.GetBySystemName(region);
  var s3SignatureVersionOverride
    = endpoint.GetEndpointForService("s3",
                                     Config.ToGetEndpointForServiceOptions())
              .SignatureVersionOverride;

  ....

  if (   endpoint?.SystemName == RegionEndpoint.USEast1.SystemName
      && fallbackToSigV2)
  {
    signatureVersionToUse = SignatureVersion.SigV2;
  }
  ....
}

Ryujinx

V3095 The 'owner' object was used before it was verified against null. Check lines: 169, 174. KThread.cs 169


public Result Initialize(....)
{
  ....
  if (type == ThreadType.User)
  {
    if (   owner.AllocateThreadLocalStorage(out _tlsAddress)  // <=
        != Result.Success)
    {
      return KernelResult.OutOfMemory;
    }

    MemoryHelper.FillWithZeros(owner.CpuMemory,
                               _tlsAddress,
                               KTlsPageInfo.TlsEntrySize);
  }

  if (owner != null)  // <=
  {
    Owner = owner;
    owner.IncrementReferenceCount();
    owner.IncrementThreadCount();
    ....
  }
  else
  {
    is64Bits = true;
  }
}

Microsoft PowerToys

V3095 The 'query' object was used before it was verified against null. Check lines: 56, 60. Main.cs 56


public List<Result> Query(Query query)
{
  bool isGlobalQuery = string.IsNullOrEmpty(query.ActionKeyword); // <=
  ....

  if (query == null) // <=
  {
    throw new ArgumentNullException(paramName: nameof(query));
  }

  // Happens if the user has only typed the action key so far
  if (string.IsNullOrEmpty(query.Search))
  {
    return new List<Result>();
  }
}

Microsoft PowerToys

V3095 The '_viewModel.Results' object was used before it was verified against null. Check lines: 542, 563. MainWindow.xaml.cs 542


private void SuggestionsList_SelectionChanged(....)
{
  ListView listview = (ListView)sender;
  _viewModel.Results.SelectedItem =          // <=
    (ResultViewModel)listview.SelectedItem;
  if (e.AddedItems.Count > 0 && e.AddedItems[0] != null)
  {
    ....
  }

  if (_viewModel.Results != null &&                       // <=
      !string.IsNullOrEmpty(SearchBox.QueryTextBox.Text))
  {
    ....
  }
}

SanAndreasUnity

V3095 The 'prefab' object was used before it was verified against null. Check lines: 669, 673. NetworkClient.cs 669


public static void RegisterPrefab(GameObject prefab, Guid newAssetId, ....)
{
  if (newAssetId == Guid.Empty)
  {
    Debug.LogError($"Could not register handler for '{prefab.name}'
      with new assetId because the new assetId was empty");
    return;
  }
  if (prefab == null)
  {
    Debug.LogError("Could not register handler for prefab
      because the prefab was null");
    return;
  }
  ....
}

SanAndreasUnity

V3095 The 'aoi' object was used before it was verified against null. Check lines: 1464, 1546. NetworkServer.cs 1464


static void RebuildObserversCustom(NetworkIdentity identity, bool initialize)
{
  newObservers.Clear();
  if (identity.visible != Visibility.ForceHidden)
  {
    aoi.OnRebuildObservers(identity, newObservers);
    }
  ....
  // this code is from UNET, it's a bit strange but it works:
  if (initialize)
  {
    if (!newObservers.Contains(localConnection))
    {
      if (aoi != null)
          aoi.SetHostVisibility(identity, false);
    }
  }
}

Power-Fx

V3095 [CWE-476] The 'entry.Value' object was used before it was verified against null. Check lines: 191, 193. ExpandQueryOptions.cs 191


public static Dictionary<ExpandPath, ExpandQueryOptions>
  MergeQueryOptions(Dictionary<ExpandPath, ExpandQueryOptions> left,
                    Dictionary<ExpandPath, ExpandQueryOptions> right)
{
  var merged = new Dictionary<ExpandPath, ExpandQueryOptions>(left);
  foreach (var entry in right)
  {
    if (!merged.TryGetValue(entry.Value.ExpandInfo.ExpandPath,
                            out var selectedProjection))
    {
      merged[entry.Value.ExpandInfo.ExpandPath] = entry.Value?.Clone();
    }
    else
    {
      MergeQueryOptions(selectedProjection, entry.Value);
    }
  }

    return merged;
}

Similar errors can be found in some other places:

  • V3095 [CWE-476] The 'expand' object was used before it was verified against null. Check lines: 241, 243. ExpandQueryOptions.cs 241
  • V3095 [CWE-476] The 'Function' object was used before it was verified against null. Check lines: 405, 408. DelegationValidationStrategy.cs 405
  • V3095 [CWE-476] The 'args' object was used before it was verified against null. Check lines: 63, 70. CallNode.cs 63
  • And 10 additional diagnostic messages.

.NET 8

V3095 The 'resolvedType' object was used before it was verified against null. Check lines: 34, 55. TypeHierarchyCache.cs 34


private HierarchyFlags GetFlags (TypeDefinition resolvedType)
{
  if (_cache.TryGetValue (resolvedType, out var flags))
  {
    return flags;
  }

  if (   resolvedType.Name == "IReflect"                // <=
      && resolvedType.Namespace == "System.Reflection")
  {
    flags |= HierarchyFlags.IsSystemReflectionIReflect;
  }
  ....
  if (resolvedType != null)                             // <=
    _cache.Add (resolvedType, flags);

  return flags;
}

nopCommerce

V3095 The 'refundPaymentRequest.Order' object was used before it was verified against null. Check lines: 597, 600. CyberSourceService.cs 597


public async Task<....> RefundAsync(.... refundPaymentRequest)
{
  ....
   var clientReferenceInformation =
         new Ptsv2paymentsClientReferenceInformation(Code: refundPaymentRequest
                                                                    .Order
                                                                    ?.OrderGuid
                                                                    .ToString(),
                                                                    ....);
  ....
  if (refundPaymentRequest.Order.AllowStoringCreditCardNumber)            // <=
  {
    var cardInformation = new Ptsv2paymentsidrefundsPaymentInformationCard(
     Number: CreditCardHelper.RemoveSpecialCharacters(
                                _encryptionService
                                        .DecryptText(refundPaymentRequest
                                                         .Order
                                                         ?.CardNumber)),

     ExpirationMonth: _encryptionService.DecryptText(refundPaymentRequest
                                                         .Order
                                                         ?.CardExpirationMonth),

     ExpirationYear: _encryptionService.DecryptText(refundPaymentRequest
                                                        .Order
                                                        ?.CardExpirationYear));
    ....

  }
  ....
  var result = await apiInstance.RefundCaptureAsync(
                                   refundCaptureRequest: requestObj,
                                   id:       refundPaymentRequest
                                                 .Order
                                                 ?.CaptureTransactionId
                                         ??
                                             refundPaymentRequest
                                                 .Order
                                                 ?.AuthorizationTransactionId);
  ....
}