diff options
author | Caolán McNamara <caolanm@redhat.com> | 2023-01-29 20:59:44 +0000 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-06-27 22:37:57 +0200 |
commit | 1b3963b93866680621016860276f53ae428ec6ad (patch) | |
tree | 97c9fbb430770d4d0e93cc48f9b39af125687df1 /sc | |
parent | 93c6fdc58d577d059968a71ae08b80096f73ef1a (diff) |
crashtesting: crash in ReadQsiforum-mso-en4-30276.xls
on duplicate names where during import an existing ScRangeData using the
name is deleted on inserting a new one, leaving a XclImpName behind that
still references the deleted ScRangeData. Reverse the order of lookup
of XclImpName so we find the duplicate that references the valid
ScRangeData first.
likely also
forums/xls/forum-mso-en4-69844.xls
forums/xls/forum-mso-en4-69589.xls
forums/xls/forum-mso-en4-69308.xls
see also:
commit 657b3c889ae107d9ccaaab569929a3a1abde3200
Date: Sat Jan 21 00:08:29 2012 -0500
fdo#44831: Named range should overwrite existing name.
When inserting a new named range, it should overwrite any existing
name if one exists.
Change-Id: I275663cacc34a2b85080c038dc5a199563f3547c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146310
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit ea093514e4fc3a66f57e07486863c22e32db4245)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153380
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/excel/xiname.cxx | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sc/source/filter/excel/xiname.cxx b/sc/source/filter/excel/xiname.cxx index d498dfba492c..cd9e92dfaa93 100644 --- a/sc/source/filter/excel/xiname.cxx +++ b/sc/source/filter/excel/xiname.cxx @@ -291,8 +291,15 @@ const XclImpName* XclImpNameManager::FindName( std::u16string_view rXclName, SCT { const XclImpName* pGlobalName = nullptr; // a found global name const XclImpName* pLocalName = nullptr; // a found local name - for( const auto& rxName : maNameList ) + // If a duplicate name is seen by ScRangeName::insert then the existing + // name is erased and the new one inserted, so in the case of duplicates + // the last one seen is valid and the others invalid. So do this lookup in + // reverse in order to return the XclImpName* that references the valid + // entry (see tdf#44831 for the insert behavior and 'forum-mso-en4-30276.xls' + // for an example of this problem) + for (auto itName = maNameList.rbegin(); itName != maNameList.rend(); ++itName) { + const auto& rxName = *itName; if( rxName->GetXclName() == rXclName ) { if( rxName->GetScTab() == nScTab ) |