forked from amazingfate/loongoffice
Use reverse iterators instead of manually iterating
backwards and using an invalid iterator of
`std::vector::begin() - 1` that triggered
/usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/debug/safe_iterator.h:1103:
In function:
_Self gnu_debug::operator-(const _Self &, difference_type)
Error: attempt to retreat a dereferenceable (start-of-sequence) iterator 1
steps, which falls outside its valid range.
Objects involved in the operation:
iterator @ 0x7ffe4f131df8 {
type = gnu_cxx::normal_iterator<std::shared_ptr<std::debug::vector<rtl::Reference<sdext::presenter::PresenterToolBar::Element>, std::allocator<rtl::Reference<sdext::presenter::PresenterToolBar::Element> > > >*, std::vector<std::shared_ptr<std::debug::vector<rtl::Reference<sdext::presenter::PresenterToolBar::Element>, std::allocator<rtl::Reference<sdext::presenter::PresenterToolBar::Element> > > >, std::allocator<std::shared_ptr<std::debug::vector<rtl::Reference<sdext::presenter::PresenterToolBar::Element>, std::allocator<rtl::Reference<sdext::presenter::PresenterToolBar::Element> > > > > > > (mutable iterator);
state = dereferenceable (start-of-sequence);
references sequence with type 'std::debug::vector<std::shared_ptr<std::debug::vector<rtl::Reference<sdext::presenter::PresenterToolBar::Element>, std::allocator<rtl::Reference<sdext::presenter::PresenterToolBar::Element> > > >, std::allocator<std::shared_ptr<std::debug::vector<rtl::Reference<sdext::presenter::PresenterToolBar::Element>, std::allocator<rtl::Reference<sdext::presenter::PresenterToolBar::Element> > > > > >' @ 0x55ee4e1a92a8
}
when starting Impress with SAL_RTL_ENABLED=1 and
then starting a slideshow with Presenter Console
enabled. for an `--enable-dbgutil` Linux build.
Replace the hard-coded `nIndex=2` with
`nIndex = aPartSizes.size() - 1` (there are 3
vector elements) and rename `iBegin` to `iFirst`
(as it no longer is the begin iterator, but points
to the first element in the vector, i.e. the element
at index 0, not the first one when reverse-iterating).
Change-Id: Ibfc3b776391dae8b986964ef8f8d3c256f12d553
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185381
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
(cherry picked from commit 140fb3b98b4f8e1331634213a0825fbe92ccda15)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185427
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>