diff options
author | Caolán McNamara <caolanm@redhat.com> | 2023-01-29 20:59:44 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-01-30 08:50:07 +0000 |
commit | ea093514e4fc3a66f57e07486863c22e32db4245 (patch) | |
tree | db9933351703e0e19be09a5a743b36c62561a648 /sc | |
parent | 441d0b0fb2eef890a465c061a3d68a07c4a51832 (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>
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 ) |