Skip to content

Commit c3f7c03

Browse files
committed
Fix UB in item view controller refocusing during redraw
See merge request OpenMW/openmw!4948 (cherry-picked from 081cf2c)
1 parent c5779d7 commit c3f7c03

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

apps/openmw/mwgui/itemview.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ namespace MWGui
8282

8383
if (Settings::gui().mControllerMenus)
8484
{
85-
mControllerFocus = std::clamp(mControllerFocus, 0, mItemCount - 1);
85+
mControllerFocus = -1;
86+
if (mItemCount > 0)
87+
mControllerFocus = std::clamp(mControllerFocus, 0, mItemCount - 1);
8688
updateControllerFocus(-1, mControllerFocus);
8789
}
8890

0 commit comments

Comments
 (0)