openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1801502 - /openoffice/trunk/main/comphelper/source/container/enumhelper.cxx
Date Mon, 10 Jul 2017 17:13:49 GMT
Author: damjan
Date: Mon Jul 10 17:13:49 2017
New Revision: 1801502

URL: http://svn.apache.org/viewvc?rev=1801502&view=rev
Log:
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

Modified:
    openoffice/trunk/main/comphelper/source/container/enumhelper.cxx

Modified: openoffice/trunk/main/comphelper/source/container/enumhelper.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/comphelper/source/container/enumhelper.cxx?rev=1801502&r1=1801501&r2=1801502&view=diff
==============================================================================
--- openoffice/trunk/main/comphelper/source/container/enumhelper.cxx (original)
+++ openoffice/trunk/main/comphelper/source/container/enumhelper.cxx Mon Jul 10 17:13:49 2017
@@ -188,15 +188,14 @@ staruno::Any SAL_CALL OEnumerationByInde
     ::osl::ResettableMutexGuard aLock(m_aLock);
 
 	staruno::Any aRes;
-	if (m_xAccess.is())
-	{
-		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())
+        aRes = m_xAccess->getByIndex(m_nPos++);
+
+    if (m_xAccess.is() && m_nPos >= m_xAccess->getCount())
+    {
+        impl_stopDisposeListening();
+        m_xAccess.clear();
+    }
 
 	if (!aRes.hasValue())		// es gibt kein Element mehr
 		throw starcontainer::NoSuchElementException();



Mime
View raw message