[Libreoffice-commits] core.git: svl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Oct 5 11:33:04 UTC 2018


 svl/source/notify/broadcast.cxx |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

New commits:
commit a20ec3b5cd691ae18f0d87d045673ce3a06579c6
Author:     Noel Grandin <noel at peralex.com>
AuthorDate: Fri Oct 5 09:37:09 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Oct 5 13:32:37 2018 +0200

    fix iterator invalidation assert
    
    which only recent versions of MSVC (from 15.8.6) seem to spot.
    It resulted in PythonTest_sw_python failures with "vector
    iterators incompatible" assertion on the
        dest != maDestructedListeners.end()
    check
    
    ever since
        commit 4a290888580474f9542f185091bb2a6fcf4e9a53
        Date:   Mon Oct 1 14:31:00 2018 +0200
        SvtBroadcaster unify the normal and PrepareForDestruction paths
    
    Although this code appears to always have been wrong, it is just
    that it is being hit much more often now.
    
    Change-Id: I45d4f2ceef4ddf19c205702645a41363eea93f21
    Reviewed-on: https://gerrit.libreoffice.org/61397
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/svl/source/notify/broadcast.cxx b/svl/source/notify/broadcast.cxx
index 7e67de0bcdf1..bef049a84c5c 100644
--- a/svl/source/notify/broadcast.cxx
+++ b/svl/source/notify/broadcast.cxx
@@ -94,15 +94,16 @@ SvtBroadcaster::~SvtBroadcaster()
     Normalize();
 
     {
+        auto dest(maDestructedListeners.data());
         SfxHint aHint(SfxHintId::Dying);
-        ListenersType::const_iterator dest(maDestructedListeners.begin());
         for (ListenersType::iterator it(maListeners.begin()); it != maListeners.end(); ++it)
         {
+            auto destEnd(dest + maDestructedListeners.size());
             // skip the destructed ones
-            while (dest != maDestructedListeners.end() && (*dest < *it))
+            while (dest != destEnd && (*dest < *it))
                 ++dest;
 
-            if (dest == maDestructedListeners.end() || *dest != *it)
+            if (dest == destEnd || *dest != *it)
                 (*it)->Notify(aHint);
         }
     }
@@ -113,14 +114,15 @@ SvtBroadcaster::~SvtBroadcaster()
     // listeners, with the exception of those that already asked to be removed
     // during their own destruction
     {
-        ListenersType::const_iterator dest(maDestructedListeners.begin());
+        auto dest(maDestructedListeners.data());
         for (ListenersType::iterator it(maListeners.begin()); it != maListeners.end(); ++it)
         {
+            auto destEnd(dest + maDestructedListeners.size());
             // skip the destructed ones
-            while (dest != maDestructedListeners.end() && (*dest < *it))
+            while (dest != destEnd && (*dest < *it))
                 ++dest;
 
-            if (dest == maDestructedListeners.end() || *dest != *it)
+            if (dest == destEnd || *dest != *it)
                 (*it)->BroadcasterDying(*this);
         }
     }


More information about the Libreoffice-commits mailing list