From 96d5134d4ddf66c517c6a024c2624ee0a8cc9ac4 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 14 Sep 2012 21:53:00 +0200 Subject: SfxStyleSheetBasePool::Remove: fix valgrind warning: aStyles contains rtl::References, so the erase() call may cause "p" to be deleted, while "p" is then used as a parameter to Broadcast; avoid this by retaining the rtl::Reference on the stack a bit longer. Valgrind warning observed in sc_unoapi sc.ScStyleFamilyObj on libreoffice-3-6 branch, called by ScStyleFamilyObj::removeByName. Change-Id: I96d6de85b1b182b5ae3f74e92987a7f137537ffb --- svl/source/items/style.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'svl') diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx index 3f6b768e6feb..2a434b857a1b 100644 --- a/svl/source/items/style.cxx +++ b/svl/source/items/style.cxx @@ -740,7 +740,10 @@ void SfxStyleSheetBasePool::Remove( SfxStyleSheetBase* p ) { if( p ) { - SfxStyles::iterator aIter( std::find( aStyles.begin(), aStyles.end(), rtl::Reference< SfxStyleSheetBase >( p ) ) ); + // Reference to keep p alive until after Broadcast call! + rtl::Reference xP(p); + SfxStyles::iterator const aIter( + std::find(aStyles.begin(), aStyles.end(), xP)); if( aIter != aStyles.end() ) { // Alle Styles umsetzen, deren Parent dieser hier ist -- cgit