Repository :
https://github.com/FarGroup/FarManager
On branch : master
Link :
https://github.com/FarGroup/FarManager/commit/798c2932c4dca01408321da8135419102368cfc5
>---------------------------------------------------------------
commit 798c2932c4dca01408321da8135419102368cfc5
Author: Alex Alabuzhev <
alab...@gmail.com>
Date: Tue Mar 7 17:10:35 2023 +0000
gh-650: Pressing Ctrl+Enter in the find all menu of the Editor crashes Far if all entries are filtered out
>---------------------------------------------------------------
798c2932c4dca01408321da8135419102368cfc5
far/changelog | 7 ++++++-
far/editor.cpp | 3 +++
far/vbuild.m4 | 2 +-
far/vmenu.cpp | 37 +++++++++++++++++--------------------
4 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/far/changelog b/far/changelog
index b96c184df..daffab148 100644
--- a/far/changelog
+++ b/far/changelog
@@ -1,7 +1,12 @@
+--------------------------------------------------------------------------------
+drkns 2023-03-07 17:10:01+00:00 - build 6113
+
+1. gh-650: Pressing Ctrl+Enter in the find all menu of the Editor crashes Far if all entries are filtered out.
+
--------------------------------------------------------------------------------
drkns 2023-03-07 16:29:53+00:00 - build 6112
-1. gh-647: Selection not removed in Editor and edit controls on pressing Ctrl+Num6
+1. gh-647: Selection not removed in Editor and edit controls on pressing Ctrl+Num6.
--------------------------------------------------------------------------------
drkns 2023-03-05 21:10:37+00:00 - build 6111
diff --git a/far/editor.cpp b/far/editor.cpp
index 78aba67d8..8976e488a 100644
--- a/far/editor.cpp
+++ b/far/editor.cpp
@@ -3761,6 +3761,9 @@ bool Editor::Search(bool Next)
case KEY_CTRL|KEY_MSLCLICK:
case KEY_RCTRL|KEY_MSLCLICK:
{
+ if (SelectedPos == -1)
+ break;
+
const auto& coord = *FindAllList->GetComplexUserDataPtr<FindCoord>(SelectedPos);
GoToLine(coord.Line);
m_it_CurLine->SetCurPos(coord.Pos);
diff --git a/far/vbuild.m4 b/far/vbuild.m4
index e154c2045..e575ab745 100644
--- a/far/vbuild.m4
+++ b/far/vbuild.m4
@@ -1 +1 @@
-6112
+6113
diff --git a/far/vmenu.cpp b/far/vmenu.cpp
index 875daaba3..41a0d8cbd 100644
--- a/far/vmenu.cpp
+++ b/far/vmenu.cpp
@@ -871,35 +871,32 @@ long long VMenu::VMProcess(int OpCode, void* vParam, long long iParam)
case MCODE_F_MENU_GETHOTKEY:
case MCODE_F_MENU_GETVALUE: // S=Menu.GetValue([N])
{
- intptr_t Param = iParam;
-
- if (Param == -1)
- Param = SelectPos;
+ if (iParam == -1)
+ iParam = SelectPos;
else
- Param = VisualPosToReal(Param);
+ iParam = VisualPosToReal(static_cast<int>(iParam));
- if (Param>=0 && Param<static_cast<intptr_t>(Items.size()))
+ if (iParam < 0 || iParam >= static_cast<long long>(Items.size()))
+ return 0;
+
+ const auto& menuEx = at(iParam);
+ if (OpCode == MCODE_F_MENU_GETVALUE)
{
- const auto& menuEx = at(Param);
- if (OpCode == MCODE_F_MENU_GETVALUE)
- {
- *static_cast<string*>(vParam) = menuEx.Name;
- return 1;
- }
- else
- {
- return GetHighlights(&menuEx);
- }
+ *static_cast<string*>(vParam) = menuEx.Name;
+ return 1;
+ }
+ else
+ {
+ return GetHighlights(&menuEx);
}
-
- return 0;
}
case MCODE_F_MENU_ITEMSTATUS: // N=Menu.ItemStatus([N])
{
- if (iParam == -1LL)
+ if (iParam == -1)
iParam = SelectPos;
- else if (iParam >= static_cast<int>(size()) || iParam <= -1LL)
+
+ if (iParam < 0 || iParam >= static_cast<long long>(size()))
return -1;
const auto& menuEx = at(iParam);