OSDN Git Service

DirView.cpp: Fix crash when hitting Next File icon repeatedly
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Mon, 18 Jan 2021 23:46:07 +0000 (08:46 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Mon, 18 Jan 2021 23:46:07 +0000 (08:46 +0900)
Src/DirView.cpp

index f6019ee..419f069 100644 (file)
@@ -2121,11 +2121,12 @@ bool CDirView::IsLastFile()
 
 void CDirView::OpenNextFile()
 {
+       const int count = m_pList->GetItemCount();
        int currentInd = GetFocusedItem();
        int nextInd = currentInd + 1;
        if (currentInd >= 0)
        {
-               while (true)
+               while (nextInd < count)
                {
                        DIFFITEM& dip = GetDiffItem(nextInd);
                        MoveFocus(nextInd - 1, nextInd, 1);