summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-09-14 21:53:00 +0200
committerMichael Stahl <mstahl@redhat.com>2012-09-14 22:01:55 +0200
commit96d5134d4ddf66c517c6a024c2624ee0a8cc9ac4 (patch)
tree9f0443ede51ad4fb95cd7cec196dc88765be1c41
parentc3da81104bf6b82a3688c82ed341666c8f5eeec0 (diff)
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
-rw-r--r--svl/source/items/style.cxx5
1 files changed, 4 insertions, 1 deletions
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<SfxStyleSheetBase> 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