include/comphelper/interfacecontainer4.hxx |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

New commits:
commit c022b7a169eebf15f38db0286660ac84cc537358
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue May 24 14:06:51 2022 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Tue May 24 21:17:58 2022 +0200

    fix thread-safety in OInterfaceContainerHelper4
    
    we need thread-safety here (even though we use a mutex), because we use
    a singleton, and the singleton can be ref-counted when the
    OInterfaceContainerHelper4 is deleted, and is generallly not held at
    that point, and that is tricky to enforce.
    
    Change-Id: I1d61495786d5f0e18deae724b2eb6c6645feb51a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134872
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/include/comphelper/interfacecontainer4.hxx 
b/include/comphelper/interfacecontainer4.hxx
index fe19bab4e43e..694e5b17bbca 100644
--- a/include/comphelper/interfacecontainer4.hxx
+++ b/include/comphelper/interfacecontainer4.hxx
@@ -86,7 +86,9 @@ public:
 
 private:
     OInterfaceContainerHelper4<ListenerT>& rCont;
-    o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>> maData;
+    o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>,
+                      o3tl::ThreadSafeRefCountingPolicy>
+        maData;
     sal_Int32 nRemain;
 
     OInterfaceIteratorHelper4(const OInterfaceIteratorHelper4&) = delete;
@@ -228,13 +230,19 @@ public:
 
 private:
     friend class OInterfaceIteratorHelper4<ListenerT>;
-    o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>> maData;
+    o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>,
+                      o3tl::ThreadSafeRefCountingPolicy>
+        maData;
     OInterfaceContainerHelper4(const OInterfaceContainerHelper4&) = delete;
     OInterfaceContainerHelper4& operator=(const OInterfaceContainerHelper4&) = 
delete;
 
-    static o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>>& 
DEFAULT()
+    static o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>,
+                             o3tl::ThreadSafeRefCountingPolicy>&
+    DEFAULT()
     {
-        static o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>> 
SINGLETON;
+        static o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>,
+                                 o3tl::ThreadSafeRefCountingPolicy>
+            SINGLETON;
         return SINGLETON;
     }
 

Reply via email to