runtime: Microsoft.VisualBasic.Strings.Left(String, Int32) crashes with null ref when length is negative
Repo: Call method with negative Length (e.g. Strings.Left(string.Empty, -1);)
Expected: System.ArgumentException (Argument ‘Length’ must be greater or equal to zero.)
Actual: System.ArgumentNullException (Value cannot be null.)
Looks like it can’t find the resource Argument_GEZero1 for some reason. Output from a (tweaked) test I’m working on for dotnet/runtime#19615.
Microsoft.VisualBasic.Tests.StringsTests.LeftTest(str: null, length: -1, valid: False, expected: \"\") [FAIL]
System.ArgumentNullException : Value cannot be null.
Parameter name: format
Stack Trace:
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.Format(String format, Object[] args)
R:\corefx\src\Common\src\System\SR.vb(64,0): at System.SR.Format(String resourceFormat, Object[] args)
R:\corefx\src\Microsoft.VisualBasic\src\Microsoft\VisualBasic\CompilerServices\Utils.LateBinder.vb(86,0): at Microsoft.VisualBasic.CompilerServices.Utils.GetResourceString(String resourceKey, String[] args)
R:\corefx\src\Microsoft.VisualBasic\src\Microsoft\VisualBasic\Strings.vb(38,0): at Microsoft.VisualBasic.Strings.Left(String str, Int32 length)
R:\corefx\src\Microsoft.VisualBasic\tests\StringsTests.cs(121,0): at Microsoft.VisualBasic.Tests.StringsTests.LeftTest(String str, Int32 length, Boolean valid, String expected)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 23 (20 by maintainers)
The test method doesn’t even exist anymore:
findstr /si /C:"LeftTest" *--> nothing The resource exists:findstr /si /C:"Argument_GEZero1" *-->Microsoft.VisualBasic\src\Resources\Strings.resx: <data name="Argument_GEZero1" xml:space="preserve">I think we are safe to close. Feel free to reopen if I missed something.