[Libreoffice-commits] core.git: comphelper/source

Damjan Jovanovic damjan at apache.org
Sun Aug 27 13:04:18 UTC 2017


 comphelper/source/container/enumhelper.cxx |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

New commits:
commit 920b5ac7e809bce39ae9f81172f4d3cf664c08fd
Author: Damjan Jovanovic <damjan at apache.org>
Date:   Mon Jul 10 17:13:49 2017 +0000

    If called on an empty collection, don't let OEnumerationByIndex.nextElement()
    
    call XIndexAccess.getByIndex() with an invalid index, just like
    OEnumerationByName.nextElement() doesn't.
    
    Patch by: me
    
    (cherry picked from commit efa52a41051df84e03fc38aaeae0f6312eb2df4c)
    
    Change-Id: Id49e45c18ed00de499cfd93e0945cecaed788ae4
    Reviewed-on: https://gerrit.libreoffice.org/41574
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/comphelper/source/container/enumhelper.cxx b/comphelper/source/container/enumhelper.cxx
index c5e49a6555c8..b62838d3b39c 100644
--- a/comphelper/source/container/enumhelper.cxx
+++ b/comphelper/source/container/enumhelper.cxx
@@ -170,14 +170,13 @@ css::uno::Any SAL_CALL OEnumerationByIndex::nextElement(  )
     ::osl::ResettableMutexGuard aLock(m_aLock);
 
     css::uno::Any aRes;
-    if (m_xAccess.is())
-    {
+    if (m_xAccess.is() && m_nPos < m_xAccess->getCount())
         aRes = m_xAccess->getByIndex(m_nPos++);
-        if (m_nPos >= m_xAccess->getCount())
-        {
-            impl_stopDisposeListening();
-            m_xAccess.clear();
-        }
+
+    if (m_xAccess.is() && m_nPos >= m_xAccess->getCount())
+    {
+        impl_stopDisposeListening();
+        m_xAccess.clear();
     }
 
     if (!aRes.hasValue())


More information about the Libreoffice-commits mailing list