From 72827968e606adcdf8c16e5381b887180975ae46 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 28 May 2014 11:07:09 +0300 Subject: Try to avoid "attempt to erase from container with a past-the-end iterator" I saw such an error (and the resulting abort) in CppunitTest_sw_ooxmlexport, and the helpful backtrace displayed (it was on Linux) indicated it was caused by the erase() call in SfxListener::RemoveBroadcaster_Impl(). (Obviously this was when building against the debugging C++ runtime, i.e. --enable-dbgutil.) Unfortunately this seems to be one of those random error conditions that are hard to reproduce. At least I could not. But this is hopefully an obvious improvement. Change-Id: I0f247cf8f9fd0c151aafa59c43a49c100c518f19 --- svl/source/notify/lstner.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'svl/source') diff --git a/svl/source/notify/lstner.cxx b/svl/source/notify/lstner.cxx index 606b9a609c10..562f42c3da60 100644 --- a/svl/source/notify/lstner.cxx +++ b/svl/source/notify/lstner.cxx @@ -59,7 +59,9 @@ SfxListener::~SfxListener() void SfxListener::RemoveBroadcaster_Impl( SfxBroadcaster& rBroadcaster ) { - aBCs.erase( std::find( aBCs.begin(), aBCs.end(), &rBroadcaster ) ); + SfxBroadcasterArr_Impl::iterator aIter = std::find( aBCs.begin(), aBCs.end(), &rBroadcaster ); + if ( aIter != aBCs.end() ) + aBCs.erase( aIter ); } -- cgit