From c022b7a169eebf15f38db0286660ac84cc537358 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 24 May 2022 14:06:51 +0200 Subject: 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 --- include/comphelper/interfacecontainer4.hxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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& rCont; - o3tl::cow_wrapper>> maData; + o3tl::cow_wrapper>, + o3tl::ThreadSafeRefCountingPolicy> + maData; sal_Int32 nRemain; OInterfaceIteratorHelper4(const OInterfaceIteratorHelper4&) = delete; @@ -228,13 +230,19 @@ public: private: friend class OInterfaceIteratorHelper4; - o3tl::cow_wrapper>> maData; + o3tl::cow_wrapper>, + o3tl::ThreadSafeRefCountingPolicy> + maData; OInterfaceContainerHelper4(const OInterfaceContainerHelper4&) = delete; OInterfaceContainerHelper4& operator=(const OInterfaceContainerHelper4&) = delete; - static o3tl::cow_wrapper>>& DEFAULT() + static o3tl::cow_wrapper>, + o3tl::ThreadSafeRefCountingPolicy>& + DEFAULT() { - static o3tl::cow_wrapper>> SINGLETON; + static o3tl::cow_wrapper>, + o3tl::ThreadSafeRefCountingPolicy> + SINGLETON; return SINGLETON; } -- cgit