From 136d067eed66204cc50c528812e7ad00104751cb Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 24 Nov 2025 14:27:03 +0100 Subject: [PATCH] Scrollbar: fixed a codepath leading to a divide-by-zero. (#9089) --- docs/CHANGELOG.txt | 3 +++ imgui_widgets.cpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 68c4096d0..82c81a6ff 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -43,6 +43,9 @@ Breaking Changes: Other Changes: +- Scrollbar: fixed a codepath leading to a divide-by-zero (which would not be + noticeable by user but detected by sanitizers). (#9089) [@judicaelclair] + ----------------------------------------------------------------------- VERSION 1.92.5 (Released 2025-11-20) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index a4b3e7ed1..9009bbc8c 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1037,6 +1037,8 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, ImS6 // V denote the main, longer axis of the scrollbar (= height for a vertical scrollbar) const float scrollbar_size_v = (axis == ImGuiAxis_X) ? bb.GetWidth() : bb.GetHeight(); + if (scrollbar_size_v < 1.0f) + return false; // Calculate the height of our grabbable box. It generally represent the amount visible (vs the total scrollable amount) // But we maintain a minimum size in pixel to allow for the user to still aim inside.