Skip to content

Commit

Permalink
Clipper: Fixed an issue where passing an out of bound index to Includ…
Browse files Browse the repository at this point in the history
…eItemByIndex() could incorrectly offset the final cursor.

One case where it would manifest was calling Combo() with an out of range index. (#8450)
  • Loading branch information
ocornut committed Mar 2, 2025
1 parent c5ade65 commit 4819eae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ Other changes:
(#8451, #7660) [@achabense]
- TextLinkOpenURL(): fixed default Win32 io.PlatformOpenInShellFn handler to
handle UTF-8 regardless of system regional settings. (#7660) [@achabense]
- Clipper: Fixed an issue where passing an out of bound index to IncludeItemByIndex()
could incorrectly offset the final cursor, even if that index was not iterated through.
One case where it would manifest was calling Combo() with an out of range index. (#8450)
- Debug Tools: Added io.ConfigDebugHighlightIdConflictsShowItemPicker (defaults to true)
to allow disabled Item Picker suggestion in user facing builds. (#7961, #7669)
- Misc: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursors
Expand Down
8 changes: 4 additions & 4 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3258,11 +3258,11 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
{
clipper->DisplayStart = ImMax(data->Ranges[data->StepNo].Min, already_submitted);
clipper->DisplayEnd = ImMin(data->Ranges[data->StepNo].Max, clipper->ItemsCount);
if (clipper->DisplayStart > already_submitted) //-V1051
clipper->SeekCursorForItem(clipper->DisplayStart);
data->StepNo++;
if (clipper->DisplayStart == clipper->DisplayEnd && data->StepNo < data->Ranges.Size)
if (clipper->DisplayStart >= clipper->DisplayEnd)
continue;
if (clipper->DisplayStart > already_submitted)
clipper->SeekCursorForItem(clipper->DisplayStart);
return true;
}

Expand All @@ -3279,7 +3279,7 @@ bool ImGuiListClipper::Step()
ImGuiContext& g = *Ctx;
bool need_items_height = (ItemsHeight <= 0.0f);
bool ret = ImGuiListClipper_StepInternal(this);
if (ret && (DisplayStart == DisplayEnd))
if (ret && (DisplayStart >= DisplayEnd))
ret = false;
if (g.CurrentTable && g.CurrentTable->IsUnfrozenRows == false)
IMGUI_DEBUG_LOG_CLIPPER("Clipper: Step(): inside frozen table row.\n");
Expand Down

0 comments on commit 4819eae

Please sign in to comment.