diff options
-rw-r--r-- | comphelper/source/container/enumhelper.cxx | 13 |
1 files changed, 6 insertions, 7 deletions
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()) |