sc/source/filter/oox/condformatbuffer.cxx |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 09d6e6c81633eef6eaecf011dc766cdc68e52fd7
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Feb 23 21:12:41 2023 +0000
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Feb 24 08:57:11 2023 +0000

    crashtesting: null-deref seen on loading forum-mso-en4-399427.xlsx
    
    and others. A problem since:
    
    commit 8c9a6abf30e9ff1ebd5647f7c271e0d64643860a
    Date:   Thu Feb 2 20:16:04 2023 +0100
    
        tdf#138601 XLSX import: fix priority of conditional formatting rules
    
    Change-Id: I663b193c5bd7c5c92d3c423e70b0f7a24e3e5d76
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147552
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sc/source/filter/oox/condformatbuffer.cxx 
b/sc/source/filter/oox/condformatbuffer.cxx
index 1abb3bf91938..ac5c2738aa47 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -1172,11 +1172,12 @@ void CondFormatBuffer::finalizeImport()
             minIndex = i;
             for (size_t j = i + 1; j < maCondFormats.size(); ++j)
             {
-                if (maCondFormats[j]->maRules.begin()->first
-                    < maCondFormats[minIndex]->maRules.begin()->first)
-                {
+                const CondFormat::CondFormatRuleMap& rNextRules = 
maCondFormats[j]->maRules;
+                const CondFormat::CondFormatRuleMap& rMinRules = 
maCondFormats[minIndex]->maRules;
+                if (rNextRules.empty() || rMinRules.empty())
+                    continue;
+                if (rNextRules.begin()->first < rMinRules.begin()->first)
                     minIndex = j;
-                }
             }
             if (i != minIndex)
                 std::swap(maCondFormats[i], maCondFormats[minIndex]);

Reply via email to