The story of how PVS-Studio found an error in the library used in… PVS-Studio

PVS-Studio warning: V3080 Possible null dereference inside method at ‘helpInfo.Left’. Consider inspecting the 2nd argument: helpInfo. Parser.cs 405

private bool DoParseArgumentsVerbs(
string[] args, object options, ref object verbInstance)
{
var verbs
= ReflectionHelper.RetrievePropertyList<VerbOptionAttribute>(options);
var helpInfo
= ReflectionHelper.RetrieveMethod<HelpVerbOptionAttribute>(options);
if (args.Length == 0)
{
if (helpInfo != null || _settings.HelpWriter != null)
{
DisplayHelpVerbText(options, helpInfo, null); // <=
}
return false;
}
....
}
private void DisplayHelpVerbText(
object options, Pair<MethodInfo,
HelpVerbOptionAttribute> helpInfo, string verb)
{
string helpText;
if (verb == null)
{
HelpVerbOptionAttribute.InvokeMethod(options, helpInfo, null, out helpText);
}
else
{
HelpVerbOptionAttribute.InvokeMethod(options, helpInfo, verb, out helpText);
}
if (_settings.HelpWriter != null)
{
_settings.HelpWriter.Write(helpText);
}
}
internal static void InvokeMethod(
object target,
Pair<MethodInfo, HelpVerbOptionAttribute> helpInfo,
string verb,
out string text)
{
text = null;
var method = helpInfo.Left;
if (!CheckMethodSignature(method))
{
throw new MemberAccessException(
SR.MemberAccessException_BadSignatureForHelpVerbOptionAttribute
.FormatInvariant(method.Name));
}
text = (string)method.Invoke(target, new object[] { verb });
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store