sc/source/filter/oox/SparklineFragment.cxx |    4 ++++
 1 file changed, 4 insertions(+)

New commits:
commit c70e355c9320e45cd3c2a22ca01557c5d5e299d9
Author:     Miklos Vajna <[email protected]>
AuthorDate: Tue Oct 14 14:54:39 2025 +0200
Commit:     Caolán McNamara <[email protected]>
CommitDate: Tue Oct 14 16:34:42 2025 +0200

    sc: fix crash in SparklineGroupsContext::onCharacters()
    
    Fixes this assertion failure in a crash report:
            
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/stl_vector.h:1230: constexpr 
std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::back() [with _Tp 
= oox::xls::Sparkline; _Alloc = std::allocator<oox::xls::Sparkline>; reference 
= oox::xls::Sparkline&]: Assertion '!this->empty()' failed.
    
    Backtrace from gdb on the core:
            #0  __GI_raise (sig=sig@entry=6) at 
../sysdeps/unix/sysv/linux/raise.c:51
            #1  0x00007f906206e7f1 in __GI_abort () at abort.c:79
            #2  0x0000000000af43ee in std::__glibcxx_assert_fail(char const*, 
int, char const*, char const*) ()
            #3  0x00007f904d07ff87 in std::vector<oox::xls::Sparkline, 
std::allocator<oox::xls::Sparkline> >::back (this=<optimized out>)
                at 
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/stl_vector.h:1228
            #4  std::vector<oox::xls::Sparkline, 
std::allocator<oox::xls::Sparkline> >::back (this=<optimized out>) at 
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/stl_vector.h:1228
            #5  oox::xls::SparklineGroupsContext::onCharacters(rtl::OUString 
const&) ()
                at sc/source/filter/oox/SparklineFragment.cxx:232
            #6  0x00007f905cf0988a in 
oox::core::ContextHandler2Helper::processCollectedChars() ()
                at include/rtl/ustring.hxx:546
            #7  0x00007f905cf09a05 in 
oox::core::ContextHandler2Helper::implEndElement (nElement=3475622, 
this=0x7f902403e880)
                at oox/source/core/contexthandler2.cxx:123
    
    gdb also points out that m_aSparklineGroups is non-empty.
    
    Change-Id: Ib368550f6db0ed7ce4fbe37e056cd416208e7fe9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192393
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sc/source/filter/oox/SparklineFragment.cxx 
b/sc/source/filter/oox/SparklineFragment.cxx
index ab0733d0efc7..c2f3acbd3617 100644
--- a/sc/source/filter/oox/SparklineFragment.cxx
+++ b/sc/source/filter/oox/SparklineFragment.cxx
@@ -229,6 +229,10 @@ void SparklineGroupsContext::onCharacters(const OUString& 
rChars)
     {
         ScDocument& rDocument = getScDocument();
         auto& rLastGroup = m_aSparklineGroups.back();
+        if (rLastGroup.getSparklines().empty())
+        {
+            return;
+        }
         auto& rLastSparkline = rLastGroup.getSparklines().back();
         ScRangeList aRange;
         if (ScRangeStringConverter::GetRangeListFromString(aRange, rChars, 
rDocument,

Reply via email to