metrica
Мы используем куки, чтобы пользоваться сайтом было удобно.
Хорошо
to the top
close form

Заполните форму в два простых шага ниже:

Ваши контактные данные:

Шаг 1
Поздравляем! У вас есть промокод!

Тип желаемой лицензии:

Шаг 2
Team license
Enterprise license
** Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности
close form
Запросите информацию о ценах
Новая лицензия
Продление лицензии
--Выберите валюту--
USD
EUR
RUB
* Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности

close form
Бесплатная лицензия PVS‑Studio для специалистов Microsoft MVP
* Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности

close form
Для получения лицензии для вашего открытого
проекта заполните, пожалуйста, эту форму
* Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности

close form
Мне интересно попробовать плагин на:
* Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности

close form
check circle
Ваше сообщение отправлено.

Мы ответим вам на


Если вы так и не получили ответ, пожалуйста, проверьте папку
Spam/Junk и нажмите на письме кнопку "Не спам".
Так Вы не пропустите ответы от нашей команды.

Вебинар: Трудности при интеграции SAST, как с ними справляться - 04.04

>
>
>
Примеры ошибок, обнаруженных с помощью …

Примеры ошибок, обнаруженных с помощью диагностики V3042

V3042. Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the same object.


Xamarin.Forms

V3042 Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the Element object Xamarin.Forms.Platform.WinRT MasterDetailPageRenderer.cs 288


void UpdateTitle()
{
  if (Element?.Detail == null)
    return;

   ((ITitleProvider)this).Title =
     (Element.Detail as NavigationPage)
       ?.CurrentPage?.Title ?? Element.Title
                            ?? Element?.Title;
}

.NET Core Libraries (CoreFX)

V3042 Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'sym' object SymbolStore.cs 56


private static void InsertChildNoGrow(Symbol child)
{
  ....
  while (sym?.nextSameName != null)
  {
    sym = sym.nextSameName;
  }

  Debug.Assert(sym != null && sym.nextSameName == null);
  sym.nextSameName = child; // <=
  ....
}

.NET Core Libraries (CoreFX)

V3042 Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'property' object JsonClassInfo.AddProperty.cs 179


internal JsonPropertyInfo CreatePolymorphicProperty(....)
{
  JsonPropertyInfo runtimeProperty
    = CreateProperty(property.DeclaredPropertyType,    // <=
                     runtimePropertyType,
                     property.ImplementedPropertyType, // <=
                     property?.PropertyInfo,           // <=
                     Type,
                     options);
  ....
}

Azure PowerShell

V3042 Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'imageAndOsType' object VirtualMachineScaleSetStrategy.cs 81


internal static ResourceConfig<VirtualMachineScaleSet>
CreateVirtualMachineScaleSetConfig(...., ImageAndOsType imageAndOsType, ....)
{
  ....
  VirtualMachineProfile = new VirtualMachineScaleSetVMProfile
  {
    OsProfile = new VirtualMachineScaleSetOSProfile
    {
        ....,
        WindowsConfiguration =
          imageAndOsType.CreateWindowsConfiguration(),  // <=
        ....,
    },
    StorageProfile = new VirtualMachineScaleSetStorageProfile
    {
        ImageReference = imageAndOsType?.Image,  // <=
        DataDisks = DataDiskStrategy.CreateVmssDataDisks(
          imageAndOsType?.DataDiskLuns, dataDisks)  // <=
    },
  },
  ....
}

Azure PowerShell

V3042 Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'existingContacts' object RemoveAzureKeyVaultCertificateContact.cs 123


public override void ExecuteCmdlet()
{
  ....
  List<PSKeyVaultCertificateContact> existingContacts;

  try
  {
    existingContacts = this.DataServiceClient.
                       GetCertificateContacts(VaultName)?.ToList();
  }
  catch (KeyVaultErrorException exception)
  {
    ....
    existingContacts = null;
  }

  foreach (var email in EmailAddress)
  {
    existingContacts.RemoveAll(....);  // <=
  }
  ....
}

osu!

V3042 [CWE-476] Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'val.NewValue' object TournamentTeam.cs 41


public TournamentTeam()
{
  Acronym.ValueChanged += val =>
  {
    if (....)
      FlagName.Value = val.NewValue.Length >= 2     // <=
        ? val.NewValue?.Substring(0, 2).ToUpper()
        : string.Empty;
  };
  ....
}

Similar errors can be found in some other places:

  • V3042 [CWE-476] Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'val.NewValue' object TournamentTeam.cs 48

osu!

V3042 [CWE-476] Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'api' object SetupScreen.cs 77


private void reload()
{
  ....
  new ActionableInfo
  {
    Label = "Current User",
    ButtonText = "Change Login",
    Action = () =>
    {
      api.Logout();     // <=
      ....
    },
    Value = api?.LocalUser.Value.Username,
    ....
  },
  ....
}

Ryujinx

V3042 Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'data' object Client.cs 254


public void ReceiveLoop(int clientId)
{
    ....
    byte[] data = Receive(clientId);

    if (data.Length == 0)
    {
        continue;
    }
    ....
}

private byte[] Receive(int clientId, int timeout = 0)
{
    ....
    var result = _client?.Receive(ref endPoint);

    if (result.Length > 0)
    {
        ....
    }

    return result;
    ....
}

LINQ to DB

V3042 Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the '_update' object SqlUpdateStatement.cs 60


public override ISqlTableSource? GetTableSource(ISqlTableSource table)
{
  ....
  if (table == _update?.Table)
    return _update.Table;
  ....
}

DotNetNuke

V3042 Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'module.DesktopModule' object Converters.cs 67


public static ModuleItem ConvertToModuleItem(ModuleInfo module)
  => new ModuleItem
{
  Id = module.ModuleID,
  Title = module.ModuleTitle,
  FriendlyName = module.DesktopModule.FriendlyName, // <=
  EditContentUrl = GetModuleEditContentUrl(module),
  EditSettingUrl = GetModuleEditSettingUrl(module),
  IsPortable = module.DesktopModule?.IsPortable,    // <=
  AllTabs = module.AllTabs,
};

DotNetNuke

V3042 Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'PortalSettings.Current' object PagesMenuController.cs 47


public IDictionary<string, object> GetSettings(MenuItem menuItem)
{
  var settings = new Dictionary<string, object>
  {
    { "canSeePagesList",
      this.securityService.CanViewPageList(menuItem.MenuId) },

    { "portalName",
      PortalSettings.Current.PortalName },              // <=

    { "currentPagePermissions",
      this.securityService.GetCurrentPagePermissions() },

    { "currentPageName",
      PortalSettings.Current?.ActiveTab?.TabName },     // <=

    { "productSKU",
      DotNetNukeContext.Current.Application.SKU },

    { "isAdmin",
      this.securityService.IsPageAdminUser() },

    { "currentParentHasChildren",
      PortalSettings.Current?.ActiveTab?.HasChildren },  // <=

    { "isAdminHostSystemPage",
      this.securityService.IsAdminHostSystemPage() },
  };

  return settings;
}

Unity C# reference source code

V3042 Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'version' object UpmPackageDocs.cs 38


public static string FetchBuiltinDescription(....)
{
  return string.IsNullOrEmpty(version?.packageInfo?.description) ?
    string.Format(L10n.Tr(....), version.displayName) :
    version.packageInfo.description.Split(....)[0];
}

Power-Fx

V3042 [CWE-476] Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'mergeExpandValue' object TabularDataQueryOptions.cs 282


internal bool AppendExpandQueryOptions(ExpandQueryOptions mergeExpandValue)
{
  ....
  ExpandQueryOptions[mergeExpandValue.ExpandInfo.ExpandPath] =
    mergeExpandValue?.Clone();
  return true;
}

Power-Fx

V3042 [CWE-476] Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'node' object ResolvedObjectHelpers.cs 45


public static FormulaValue ResolvedObjectError(ResolvedObjectNode node)
{
    return new ErrorValue(node.IRContext, new ExpressionError()
    {
        Message = $"Unrecognized symbol {node?.Value?.GetType()?.Name}".Trim(),
        Span = node.IRContext.SourceContext,
        Kind = ErrorKind.Validation
    });
}

Similar errors can be found in some other places:

  • V3042 [CWE-476] Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'node' object ResolvedObjectHelpers.cs 48

Power-Fx

V3042 [CWE-476] Possible NullReferenceException. The '?.' and '.' operators are used for accessing members of the 'other.Fields' object FormulaTypeSchema.cs 118


public override bool Equals(object o)
{
  return o is FormulaTypeSchema other &&
    Type.Equals(other.Type) &&
    Description == other.Description &&
    Help == other.Help &&
    Fields?.Count() == other.Fields?.Count() &&
    (Fields?.All(
      (thisKvp) => other.Fields.TryGetValue(thisKvp.Key, out var otherValue) &&
      (thisKvp.Value?.Equals(otherValue) ?? otherValue == null)) ?? true);
}