From 5f93f62f1cf3c8a7edd739234f850bd2ae7cbe60 Mon Sep 17 00:00:00 2001 From: MacDue Date: Fri, 5 May 2023 22:52:09 +0100 Subject: [PATCH] LibGUI: Fix ColorSlider crash when the selected hue is 360 If the ColorSlider returns a hue of 360 degrees one of the various `VERIFY(hsv.hue >= 0.0 && hsv.hue < 360.0);` in Color.h will be hit. --- Userland/Libraries/LibGUI/ColorPicker.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Userland/Libraries/LibGUI/ColorPicker.cpp b/Userland/Libraries/LibGUI/ColorPicker.cpp index 451b1679a1..f9c6c2eb68 100644 --- a/Userland/Libraries/LibGUI/ColorPicker.cpp +++ b/Userland/Libraries/LibGUI/ColorPicker.cpp @@ -705,6 +705,8 @@ void ColorSlider::pick_value_at_position(GUI::MouseEvent& event) auto inner_rect = frame_inner_rect(); auto position = event.position().constrained(inner_rect).translated(-frame_thickness(), -frame_thickness()); auto hue = (double)position.y() / inner_rect.height() * 360; + if (hue >= 360) + hue -= 360; m_last_position = position.y(); m_value = hue;