فهرست منبع

fixed overflow exception in alphanum comparer

Luke Pulverenti 11 سال پیش
والد
کامیت
ce51973a80
1فایلهای تغییر یافته به همراه8 افزوده شده و 2 حذف شده
  1. 8 2
      MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs

+ 8 - 2
MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs

@@ -78,8 +78,14 @@ namespace MediaBrowser.Server.Implementations.Sorting
                 // If both chunks contain numeric characters, sort them numerically
                 if (char.IsDigit(thisChunk[0]) && char.IsDigit(thatChunk[0]))
                 {
-                    thisNumericChunk = Convert.ToInt32(thisChunk.ToString());
-                    thatNumericChunk = Convert.ToInt32(thatChunk.ToString());
+                    if (!int.TryParse(thisChunk.ToString(), out thisNumericChunk))
+                    {
+                        return 0;
+                    }
+                    if (!int.TryParse(thatChunk.ToString(), out thatNumericChunk))
+                    {
+                        return 0;
+                    }
 
                     if (thisNumericChunk < thatNumericChunk)
                     {