summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-02-18 10:56:56 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-02-18 11:53:27 +0100
commitfe2ec505786bacc6f3baca3292367903644ac99b (patch)
tree34c79dbc66f0fef4142d6675891ea1b15a54ec3a /svl
parent657095c9d26147e290e7944db875b9555b33dd1a (diff)
improve the SfxItemSet::CloneAsValue check
to prevent object slicing. Which reveals a problems with commit 044fa30a4c77013c87a7e2a6dd9022a2f6599778 Author: Noel Grandin <noelgrandin@gmail.com> Date: Thu Sep 23 18:44:42 2021 +0200 no need to allocate this SfxItemSet on the heap and commit 044fa30a4c77013c87a7e2a6dd9022a2f6599778 Author: Noel Grandin <noelgrandin@gmail.com> 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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/items/itemset.cxx13
1 files changed, 4 insertions, 9 deletions
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> 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<SfxItemSet> SfxAllItemSet::Clone(bool bItems, SfxItemPool *pToPo
return std::unique_ptr<SfxItemSet>(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 )
{