diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2021-09-27 15:18:00 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2021-09-27 17:54:50 +0200 |
commit | d9d9bd65e22a3bd61cce6d88849a794bb0918d7b (patch) | |
tree | 3791f19932bb3097bfc7b715eb1647821d22514e /sw | |
parent | 089c7d05fde13251eb8cd8daaf7627b6bb0072f9 (diff) |
Don't dereference empty optional
...after 183729b7bdb98561dae2a3e8c9518fe4787ee6e3 "no need to allocate these
SfxItemSet on the heap", as seen causing SIGABRT at
> #1 0x00007f5b61e6a8a4 in abort () at /lib64/libc.so.6
> #2 0x00007f5b30a2414b in std::_Optional_base_impl<SfxItemSet, std::_Optional_base<SfxItemSet, false, false> >::_M_get() const (this=0x7f5ae4f52030) at ~/gcc/trunk/inst/include/c++/12.0.0/optional:443
> #3 0x00007f5b30a219bc in std::optional<SfxItemSet>::operator*() const & (this=0x7f5ae4f52030) at ~/gcc/trunk/inst/include/c++/12.0.0/optional:919
> #4 0x00007f5b30a1eb35 in FlatFndBox::GetItemSet(unsigned short, unsigned short) const (this=0x7f5b337fb730, n_Col=1, n_Row=4) at sw/source/core/doc/docsort.cxx:929
during JunitTest_sw_unoapi_4.
Change-Id: If409ce86863faf4617c636616f814237ff62c7ca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122710
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/doc/docsort.cxx | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index 24dcba033a30..fbd7ff9e9bcb 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -926,7 +926,11 @@ const SfxItemSet* FlatFndBox::GetItemSet(sal_uInt16 n_Col, sal_uInt16 n_Row) con { OSL_ENSURE( m_vItemSets.empty() || ( n_Col < m_nCols && n_Row < m_nRows), "invalid array access"); - return !m_vItemSets.empty() ? &*m_vItemSets[unsigned(n_Row * m_nCols) + n_Col] : nullptr; + if (m_vItemSets.empty()) { + return nullptr; + } + auto const & el = m_vItemSets[unsigned(n_Row * m_nCols) + n_Col]; + return el ? &*el : nullptr; } sal_uInt16 SwMovedBoxes::GetPos(const SwTableBox* pTableBox) const |