Examples of errors detected by the V3125 diagnostic.

V3125. The object was used after it was verified against null. Check lines: N1, N2.


Umbraco

V3125 The 'ct' object was used after it was verified against null. Check lines: 171, 163. ContentTypeControllerBase.cs 171


protected TContentType PerformPostSave<....>(....)
{
  var ctId = Convert.ToInt32(....);
  ....
  if (ctId > 0 && ct == null)
    throw new HttpResponseException(HttpStatusCode.NotFound);
  ....
  if ((....) &&
      (ctId == 0 || ct.Alias != contentTypeSave.Alias))
  ....
}

Identical errors can be found in some other places:

  • V3125 The '_repo' object was used after it was verified against null. Check lines: 104, 78. Installer.aspx.cs 104
  • V3125 The 'docRequest.RoutingContext.UmbracoContext' object was used after it was verified against null. Check lines: 57, 39. ContentFinderByIdPath.cs 57
  • V3125 The 'User' object was used after it was verified against null. Check lines: 90, 80. config.cs 90
  • And 5 additional diagnostic messages.

SharpDevelop

V3125 The 'mainAssemblyList' object was used after it was verified against null. Check lines: 304, 291. ClassBrowserPad.cs 304


void UpdateActiveWorkspace()
{
  var mainAssemblyList = SD.ClassBrowser.MainAssemblyList;
  if ((mainAssemblyList != null) && (activeWorkspace != null)) {
    ....
  }
  ....
  mainAssemblyList.Assemblies.Clear();
  ....
}

Media Portal 2

V3125 The 'root' object was used after it was verified against null. Check lines: 103, 98. SettingsFileHandler.cs 103


protected XmlElement GetPropertyElement(....)
{
  XmlElement root = _document.DocumentElement;
  if (root == null)
    if (!createIfNotExists)
      return null;
    else
      CreateRootElement();

  XmlElement entryElement = root.SelectSingleNode(        // <=
    "Property[@Name=\"" + entryName + "\"]") as XmlElement;
  ....
}

Identical errors can be found in some other places:

  • V3125 The 'e.Error' object was used after it was verified against null. Check lines: 467, 465. TextureAssetCore.cs 467


Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++ and C#

goto PVS-Studio;