Fix number formatting exception with empty NumberGroupSizes array (dotnet/coreclr...
authorStephen Toub <stoub@microsoft.com>
Thu, 31 May 2018 21:08:55 +0000 (17:08 -0400)
committerGitHub <noreply@github.com>
Thu, 31 May 2018 21:08:55 +0000 (17:08 -0400)
Commit migrated from https://github.com/dotnet/coreclr/commit/2a2f7af391f67c9b289456e4b5763308ed2a1b74

src/libraries/System.Private.CoreLib/src/System/Number.Formatting.cs

index 74395ab2f58ae7b90c2b413d53a749f704fb2316..387fe0193c2ba29ae88a424c900212ad2a0d3b85 100644 (file)
@@ -1974,13 +1974,14 @@ namespace System
                 if (groupDigits != null)
                 {
                     int groupSizeIndex = 0;                             // Index into the groupDigits array.
-                    int groupSizeCount = groupDigits[groupSizeIndex];   // The current total of group size.
                     int bufferSize = digPos;                            // The length of the result buffer string.
                     int groupSize = 0;                                  // The current group size.
 
                     // Find out the size of the string buffer for the result.
                     if (groupDigits.Length != 0) // You can pass in 0 length arrays
                     {
+                        int groupSizeCount = groupDigits[groupSizeIndex];   // The current total of group size.
+
                         while (digPos > groupSizeCount)
                         {
                             groupSize = groupDigits[groupSizeIndex];