From fe2ec505786bacc6f3baca3292367903644ac99b Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 18 Feb 2022 10:56:56 +0200 Subject: improve the SfxItemSet::CloneAsValue check to prevent object slicing. Which reveals a problems with commit 044fa30a4c77013c87a7e2a6dd9022a2f6599778 Author: Noel Grandin Date: Thu Sep 23 18:44:42 2021 +0200 no need to allocate this SfxItemSet on the heap and commit 044fa30a4c77013c87a7e2a6dd9022a2f6599778 Author: Noel Grandin Date: Thu Sep 23 18:44:42 2021 +0200 no need to allocate this SfxItemSet on the heap so revert the problematic bits of those commits Change-Id: I5eeba1d5bdb91f4e539850516f2b1c11e69ff2c1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130127 Tested-by: Jenkins Reviewed-by: Noel Grandin --- svl/source/items/itemset.cxx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'svl') diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index 04fab3c9306e..bfaf0a60e169 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -1251,6 +1251,10 @@ std::unique_ptr SfxItemSet::Clone(bool bItems, SfxItemPool *pToPool SfxItemSet SfxItemSet::CloneAsValue(bool bItems, SfxItemPool *pToPool ) const { + // if you are trying to clone, then the thing you are cloning is polymorphic, which means + // it cannot be cloned as a value + assert((typeid(*this) == typeid(SfxItemSet)) && "cannot call this on a subclass of SfxItemSet"); + if (pToPool && pToPool != m_pPool) { SfxItemSet aNewSet(*pToPool, m_pWhichRanges); @@ -1386,15 +1390,6 @@ std::unique_ptr SfxAllItemSet::Clone(bool bItems, SfxItemPool *pToPo return std::unique_ptr(bItems ? new SfxAllItemSet(*this) : new SfxAllItemSet(*m_pPool)); } -SfxItemSet SfxAllItemSet::CloneAsValue(bool , SfxItemPool * ) const -{ - // if you are trying to clone, then the thing you are cloning is polymorphic, which means - // it cannot be cloned as a value - throw std::logic_error("cannot do this"); -} - - - WhichRangesContainer::WhichRangesContainer( const WhichPair* wids, sal_Int32 nSize ) { -- cgit bora/cd-5.3-3.4'>distro/collabora/cd-5.3-3.4 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
path: root/mysqlc