OSDN Git Service

Fix infinite loop when comparing folders that have a item
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 10 Jan 2016 07:34:36 +0000 (16:34 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 10 Jan 2016 07:34:36 +0000 (16:34 +0900)
Src/DirItemIterator.h

index e9ee20a..6870e72 100644 (file)
@@ -138,10 +138,18 @@ public:
 
        DirItemIterator& operator++()
        {
-               m_sel = m_pList->GetNextItem(m_sel, m_selected, m_reverse);
-               m_pdi = reinterpret_cast<const DIFFITEM *>(m_pList->GetItemData(m_sel));
-               if (m_pdi == reinterpret_cast<const DIFFITEM *>(-1L))
+               if (m_reverse && m_sel <= 0)
+               {
                        m_sel = -1;
+                       m_pdi = reinterpret_cast<const DIFFITEM *>(-1L);
+               }
+               else
+               {
+                       m_sel = m_pList->GetNextItem(m_sel, m_selected, m_reverse);
+                       m_pdi = reinterpret_cast<const DIFFITEM *>(m_pList->GetItemData(m_sel));
+                       if (m_pdi == reinterpret_cast<const DIFFITEM *>(-1L))
+                               m_sel = -1;
+               }
                return *this;
        }