Check that switchKey isn't empty

This commit is contained in:
Andrew Schwartzmeyer 2016-07-01 11:18:34 -07:00
parent e3fd809d42
commit 75777b42ee

View file

@ -354,7 +354,7 @@ namespace Microsoft.PowerShell
switchKey = switchKey.Substring(1);
// chop off the second dash so we're agnostic wrt specifying - or --
if (SpecialCharacters.IsDash(switchKey[0]))
if (!String.IsNullOrEmpty(switchKey) && SpecialCharacters.IsDash(switchKey[0]))
{
switchKey = switchKey.Substring(1);
}