Compare commits

..

1 Commits

Author SHA1 Message Date
Muyuan Li (from Dev Box)
614f009378 fix(Peek): prevent OverflowException in NumberOfDigits for int.MinValue
Cast to long before Math.Abs to avoid OverflowException when num == int.MinValue,
since |int.MinValue| > int.MaxValue.

Closes #46960
2026-04-29 17:38:45 +08:00
2 changed files with 2 additions and 14 deletions

View File

@@ -16,7 +16,7 @@ namespace Peek.Common.Helpers
public static int NumberOfDigits(int num)
{
return Math.Abs(num).ToString(CultureInfo.InvariantCulture).Length;
return Math.Abs((long)num).ToString(CultureInfo.InvariantCulture).Length;
}
}
}

View File

@@ -9,7 +9,6 @@ using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
@@ -136,18 +135,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private void Frame_NavigationFailed(object sender, NavigationFailedEventArgs e)
{
var sourcePage = e.SourcePageType?.FullName ?? "<unknown>";
if (e.Exception is null)
{
Logger.LogWarning($"Navigation to '{sourcePage}' failed without an exception.");
}
else
{
Logger.LogError($"Navigation to '{sourcePage}' failed.", e.Exception);
}
e.Handled = true;
throw e.Exception;
}
private void Frame_Navigated(object sender, NavigationEventArgs e)