Fix number formatting exception with empty NumberGroupSizes array (#18221) (#18667)
authorStephen Toub <stoub@microsoft.com>
Wed, 27 Jun 2018 03:30:38 +0000 (23:30 -0400)
committerGitHub <noreply@github.com>
Wed, 27 Jun 2018 03:30:38 +0000 (23:30 -0400)
src/mscorlib/shared/System/Number.Formatting.cs

index 74395ab..387fe01 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];