sw/source/core/attr/swatrset.cxx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
New commits: commit 938a4d6624a78f3e272b3c4c07f314cb0c6db723 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Fri Nov 1 18:51:06 2019 +0100 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Mon Nov 11 11:02:31 2019 +0100 tdf#128375 sw: fix copying RES_PARATR_LIST_AUTOFMT to different SwDoc When copying the item to a different SwDoc, the items in the nested SfxItemSet must be copied into the target SwDoc's item pool, or a use-after-free is inevitable. (regression from 5ba30f588d6e41a13d68b1461345fca7a7ca61ac) Change-Id: I7071ff6dccf2285d96f540ac556b9fa2265ddf00 Reviewed-on: https://gerrit.libreoffice.org/81911 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@cib.de> diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx index 14931ed3b4cf..3870d7334afe 100644 --- a/sw/source/core/attr/swatrset.cxx +++ b/sw/source/core/attr/swatrset.cxx @@ -26,6 +26,7 @@ #include <editeng/editeng.hxx> #include <fmtanchr.hxx> #include <fmtpdsc.hxx> +#include <fmtautofmt.hxx> #include <hintids.hxx> #include <list.hxx> #include <node.hxx> @@ -395,6 +396,22 @@ void SwAttrSet::CopyToModify( SwModify& rMod ) const tmpSet->ClearItem( RES_ANCHOR ); } + if (pSrcDoc != pDstDoc && + SfxItemState::SET == GetItemState(RES_PARATR_LIST_AUTOFMT, false, &pItem)) + { + SfxItemSet const& rAutoStyle(*static_cast<SwFormatAutoFormat const&>(*pItem).GetStyleHandle()); + std::shared_ptr<SfxItemSet> const pNewSet( + rAutoStyle.SfxItemSet::Clone(true, &pDstDoc->GetAttrPool())); + SwFormatAutoFormat item(RES_PARATR_LIST_AUTOFMT); + // TODO: for ODF export we'd need to add it to the autostyle pool + item.SetStyleHandle(pNewSet); + if (!tmpSet) + { + tmpSet.reset(new SfxItemSet(*this)); + } + tmpSet->Put(item); + } + if( tmpSet ) { if( pCNd ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits