From a13badd73e3780690208fde799edb1e73c2f8377 Mon Sep 17 00:00:00 2001 From: MilosLord Date: Fri, 30 Oct 2026 11:56:02 +0100 Subject: [PATCH] MultiSelect: fixed ImGuiSelectionBasicStorage::GetNextSelectedItem() reading past the end of storage when trailing items are unselected (#9604) --- docs/CHANGELOG.txt | 3 +++ imgui_widgets.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index dddcff7a2..4ba908f4f 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -90,6 +90,9 @@ Other Changes: - Fixed selectable highlight straying off the X2/Y2 clipping limit. - Fixed parent window work rectangle affecting the Y2 clipping limit. - Fixed the Y2 clipping limit overlapping bottom outer border. +- Multi-Select: + - Fixed `ImGuiSelectionBasicStorage::GetNextSelectedItem()` reading one past the + end of storage when trailing items are unselected (#9604) [@MilosLord] - ImVec2: added a check for cases where a custom `IM_VEC2_CLASS_EXTRA` macro adds an extra `operator=` to ImVec2. This isn't supported but should not be needed as you should have a constructor to convert from your type to ImVec2. diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index e1a884429..0b862b437 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -8803,7 +8803,7 @@ bool ImGuiSelectionBasicStorage::GetNextSelectedItem(void** opaque_it, ImGuiID* it = _Storage.Data.Data; IM_ASSERT(it >= _Storage.Data.Data && it <= it_end); if (it != it_end) - while (it->val_i == 0 && it < it_end) + while (it < it_end && it->val_i == 0) it++; const bool has_more = (it != it_end); *opaque_it = has_more ? (void**)(it + 1) : (void**)(it);