summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2021-07-19 17:33:04 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2021-07-20 11:59:24 +0200
commit7d1175c46588c246c455cd7c8874136bf61197fd (patch)
tree4dde15e1ec934552ac64fbd26aec616b2d071fdd /framework
parentc1a8ff837e3e369561150c0022c6ab02aab27c2c (diff)
framework: fix multiple-free in VclToolBarManager::Destroy()
Multiple ImplToolItem with mnId 1000 are inserted in the same ToolBox and the problem is that only the first one gets its mpUserData set, because setting and getting that is based on the assumption that mnId is unique per container. So in Destroy() for every item with mnId 1000 the same AddonsParams object is deleted. The problem is that in ToolBarManager::FillToolbar() the local nItemId is copied, so its value never changes when iterating the loop because only its copy is incremented. (regression from ac1aefd5174258d9bcb41465ce566ed1a0819f3d) Change-Id: Ica47051f9447c2b9d1981f8373d754874f0f31b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119228 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/uielement/toolbarmanager.hxx2
-rw-r--r--framework/source/uielement/toolbarmanager.cxx8
-rw-r--r--framework/source/uielement/toolbarmerger.cxx2
3 files changed, 7 insertions, 5 deletions
diff --git a/framework/inc/uielement/toolbarmanager.hxx b/framework/inc/uielement/toolbarmanager.hxx
index 8a87c2a6b78a..6de526423d38 100644
--- a/framework/inc/uielement/toolbarmanager.hxx
+++ b/framework/inc/uielement/toolbarmanager.hxx
@@ -92,7 +92,7 @@ public:
virtual vcl::ImageType GetImageSize() = 0;
virtual void ConnectCallbacks(ToolBarManager* pManager) = 0;
virtual void SetMenuType(ToolBoxMenuType eType) = 0;
- virtual void MergeToolbar(ToolBoxItemId nItemId,
+ virtual void MergeToolbar(ToolBoxItemId & rItemId,
const OUString& rModuleIdentifier,
CommandToInfoMap& rCommandMap,
MergeToolbarInstruction& rInstruction) = 0;
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index f08cfe60a6d8..e85de886b442 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -333,7 +333,7 @@ public:
m_pToolBar->SetMenuType( eType );
}
- virtual void MergeToolbar(ToolBoxItemId nItemId,
+ virtual void MergeToolbar(ToolBoxItemId & rItemId,
const OUString& rModuleIdentifier,
CommandToInfoMap& rCommandMap,
MergeToolbarInstruction& rInstruction) override
@@ -349,7 +349,7 @@ public:
{
ToolBarMerger::ProcessMergeOperation( m_pToolBar,
aRefPoint.nPos,
- nItemId,
+ rItemId,
rCommandMap,
rModuleIdentifier,
rInstruction.aMergeCommand,
@@ -359,7 +359,7 @@ public:
else
{
ToolBarMerger::ProcessMergeFallback( m_pToolBar,
- nItemId,
+ rItemId,
rCommandMap,
rModuleIdentifier,
rInstruction.aMergeCommand,
@@ -521,7 +521,7 @@ public:
virtual void SetMenuType(ToolBoxMenuType /*eType*/) override {}
- virtual void MergeToolbar(ToolBoxItemId /*nItemId*/,
+ virtual void MergeToolbar(ToolBoxItemId & /*rItemId*/,
const OUString& /*rModuleIdentifier*/,
CommandToInfoMap& /*rCommandMap*/,
MergeToolbarInstruction& /*rInstruction*/) override {}
diff --git a/framework/source/uielement/toolbarmerger.cxx b/framework/source/uielement/toolbarmerger.cxx
index 652383988bcd..faba3cb4e8d9 100644
--- a/framework/source/uielement/toolbarmerger.cxx
+++ b/framework/source/uielement/toolbarmerger.cxx
@@ -623,6 +623,8 @@ rtl::Reference<::cppu::OWeakObject> ToolBarMerger::CreateController(
void ToolBarMerger::CreateToolbarItem( ToolBox* pToolbar, ToolBox::ImplToolItems::size_type nPos, ToolBoxItemId nItemId, const AddonToolbarItem& rItem )
{
+ assert(pToolbar->GetItemData(nItemId) == nullptr); // that future would contain a double free
+
pToolbar->InsertItem( nItemId, rItem.aLabel, ToolBoxItemBits::NONE, nPos );
pToolbar->SetItemCommand( nItemId, rItem.aCommandURL );
pToolbar->SetQuickHelpText( nItemId, rItem.aLabel );