Skip to content

Commit

Permalink
Fix crash caused by inputting non-digit into color picker input. (#934)
Browse files Browse the repository at this point in the history
  • Loading branch information
RegorForgot authored Aug 25, 2023
1 parent 7d8c1d5 commit a124655
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion LenovoLegionToolkit.WPF/Controls/ColorPickerControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ private static byte ToByte(string s)
if (string.IsNullOrWhiteSpace(s))
return 0;

return (byte)Math.Clamp(Convert.ToInt32(s), 0, 255);
Int32.TryParse(s, out int userInput);

return (byte)Math.Clamp(userInput, 0, 255);
}
}

0 comments on commit a124655

Please sign in to comment.