Skip to content

Commit

Permalink
Fix crash in debug builds on sending DM_LISTSETCURPOS to an empty menu
Browse files Browse the repository at this point in the history
  • Loading branch information
shmuz committed May 31, 2024
1 parent b84e5ca commit ecbce30
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions far/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
--------------------------------------------------------------------------------
shmuel 2024-05-31 15:20:31+03:00 - build 6340

1. Fix crash in debug builds on sending DM_LISTSETCURPOS to an empty menu.

--------------------------------------------------------------------------------
shmuel 2024-05-31 00:00:44+03:00 - build 6339

Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6339
6340
3 changes: 3 additions & 0 deletions far/vmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,9 @@ int VMenu::SetSelectPos(int Pos, int Direct, bool stop_on_edge)
// установить курсор и верхний элемент
int VMenu::SetSelectPos(const FarListPos *ListPos, int Direct)
{
if (Items.empty())
return -1;

const auto pos = std::clamp(ListPos->SelectPos, intptr_t{}, static_cast<intptr_t>(Items.size() - 1));
const auto Ret = SetSelectPos(pos, Direct ? Direct : pos > SelectPos? 1 : -1);

Expand Down

0 comments on commit ecbce30

Please sign in to comment.