diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-12-23 23:46:02 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-12-23 23:46:02 +0100 |
commit | bf1812806056349fd32785e1fa7ba7595c8c66fa (patch) | |
tree | 48a98c19d47171335070d081eb30171b8dc1ceb6 /svl/source/notify | |
parent | 3f47635b86ac34a0dc42d93e77bb1a3ca26f6f79 (diff) |
fix crash when erasing entry while iterating through vector
Broadcast might result in calling Remove on the same object which erases
the entry from the listeners vector. If we create a copy we can still
iterate through the vector as all iterators are still valid.
Diffstat (limited to 'svl/source/notify')
-rw-r--r-- | svl/source/notify/broadcast.cxx | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/svl/source/notify/broadcast.cxx b/svl/source/notify/broadcast.cxx index 425a1e2568cf..19abe3878684 100644 --- a/svl/source/notify/broadcast.cxx +++ b/svl/source/notify/broadcast.cxx @@ -124,7 +124,8 @@ void SvtBroadcaster::Broadcast( const SfxHint &rHint ) Normalize(); ListenersType::iterator dest(maDestructedListeners.begin()); - for (ListenersType::iterator it(maListeners.begin()); it != maListeners.end(); ++it) + ListenersType aListeners(maListeners); // this copy is important to avoid erasing entries while iterating + for (ListenersType::iterator it(aListeners.begin()); it != aListeners.end(); ++it) { // skip the destructed ones while (dest != maDestructedListeners.end() && (*dest < *it)) |