diff options
author | Damjan Jovanovic <damjan@apache.org> | 2017-07-10 17:13:49 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-08-27 15:00:39 +0200 |
commit | 920b5ac7e809bce39ae9f81172f4d3cf664c08fd (patch) | |
tree | f798fe4f2b6080b8c0ae21d2b030948811934d27 /comphelper/source | |
parent | 243c371b77f7b02d9b4cdf775a6d07ef5d67ead3 (diff) |
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@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'comphelper/source')
-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()) |