From 97d95e814f17b1722e47fecc8d1df08083112c3e Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 14 Jul 2021 15:54:53 +0200 Subject: [PATCH] Added input validation in painting gizmo (some values led to a crash) --- src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp | 2 ++ src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp | 2 ++ src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp index 4048155fe..d1927a820 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp @@ -193,6 +193,8 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l ImGui::PopTextWrapPos(); ImGui::EndTooltip(); } + // Manually inserted values aren't clamped by ImGui. Zero cursor size results in a crash. + m_cursor_radius = std::clamp(m_cursor_radius, CursorRadiusMin, CursorRadiusMax); ImGui::AlignTextToFramePadding(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp index da5972c7e..344568bff 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp @@ -343,6 +343,8 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott ImGui::PopTextWrapPos(); ImGui::EndTooltip(); } + // Manually inserted values aren't clamped by ImGui. Zero cursor size results in a crash. + m_cursor_radius = std::clamp(m_cursor_radius, CursorRadiusMin, CursorRadiusMax); ImGui::AlignTextToFramePadding(); m_imgui->text(m_desc.at("cursor_type")); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp index 92b1b6603..9ceb220d4 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp @@ -148,6 +148,8 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit) ImGui::PopTextWrapPos(); ImGui::EndTooltip(); } + // Manually inserted values aren't clamped by ImGui. Zero cursor size results in a crash. + m_cursor_radius = std::clamp(m_cursor_radius, CursorRadiusMin, CursorRadiusMax); ImGui::AlignTextToFramePadding();