sc/source/filter/oox/NamedSheetViewFragment.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 8e1efb97d177a17dbe7d4f8c3b3db5a8bc0e67d3
Author:     Miklos Vajna <[email protected]>
AuthorDate: Thu Feb 19 09:19:04 2026 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Fri Feb 20 11:34:08 2026 +0100

    sc: fix crash in NsvFilterContext::onCreateContext()
    
    gdb on the crashreport core dump:
    
            #0  __pthread_kill_implementation (no_tid=0, signo=6, 
threadid=<optimized out>) at ./nptl/pthread_kill.c:44
            #1  __pthread_kill_internal (signo=6, threadid=<optimized out>) at 
./nptl/pthread_kill.c:78
            #2  __GI___pthread_kill (threadid=<optimized out>, 
signo=signo@entry=6) at ./nptl/pthread_kill.c:89
            #3  0x0000733bce84527e in __GI_raise (sig=sig@entry=6) at 
../sysdeps/posix/raise.c:26
            #4  0x0000733bce8288ff in __GI_abort () at ./stdlib/abort.c:79
            #5  0x0000000000b142fe in std::__glibcxx_assert_fail(char const*, 
int, char const*, char const*) ()
            #6  0x0000733bb932ffef in 
std::_Optional_base_impl<oox::xls::nsv::SortRulesData, 
std::_Optional_base<oox::xls::nsv::SortRulesData, false, false> >::_M_get 
(this=<optimized out>)
                at /opt/rh/devtoolset-12/root/usr/include/c++/12/optional:475
            #7  std::_Optional_base_impl<oox::xls::nsv::SortRulesData, 
std::_Optional_base<oox::xls::nsv::SortRulesData, false, false> >::_M_get 
(this=<optimized out>)
                at /opt/rh/devtoolset-12/root/usr/include/c++/12/optional:475
            #8  std::optional<oox::xls::nsv::SortRulesData>::operator-> 
(this=<optimized out>) at 
/opt/rh/devtoolset-12/root/usr/include/c++/12/optional:966
            #9  oox::xls::nsv::NsvFilterContext::onCreateContext 
(this=0x52f16e60, nElement=<optimized out>, rAttribs=...)
                at sc/source/filter/oox/NamedSheetViewFragment.cxx:123
    
    and
    
            #9  oox::xls::nsv::NsvFilterContext::onCreateContext 
(this=0x52f16e60, nElement=<optimized out>, rAttribs=...)
                at sc/source/filter/oox/NamedSheetViewFragment.cxx:123
            123                 mrNsvFilterData.maSortRules->mnMethod = 
rAttribs.getToken(XML_sortMethod, XML_none);
            (gdb) print mrNsvFilterData.maSortRules
            $1 = std::optional [no contained value]
    
    Probably the intent was the std::optional equivalent of
    std::unique_ptr::reset(new Foo()), but reset() clears the contained
    value of an std::optional, i.e. does the opposite.
    
    I missed this while reviewing commit
    a3c94c2699b73a7d5bf2900b69043098109fa9fb (sc: add elements and parsing
    of namedSheetView*.xml files, 2026-01-21).
    
    Change-Id: Ic41fcc95cc6e8fcfb8df39f63031de66f65f461e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199689
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sc/source/filter/oox/NamedSheetViewFragment.cxx 
b/sc/source/filter/oox/NamedSheetViewFragment.cxx
index 2042f133750d..3b1747371a47 100644
--- a/sc/source/filter/oox/NamedSheetViewFragment.cxx
+++ b/sc/source/filter/oox/NamedSheetViewFragment.cxx
@@ -119,7 +119,7 @@ ContextHandlerRef 
NsvFilterContext::onCreateContext(sal_Int32 nElement,
         }
         case XNSV_TOKEN(sortRules):
         {
-            mrNsvFilterData.maSortRules.reset();
+            mrNsvFilterData.maSortRules.emplace();
             mrNsvFilterData.maSortRules->mnMethod = 
rAttribs.getToken(XML_sortMethod, XML_none);
             mrNsvFilterData.maSortRules->mbCaseSensitive
                 = rAttribs.getBool(XML_caseSensitive, false);

Reply via email to