Dmitry Timoshkov : combase: When looking up an apartment which has a given creator thread ID use multi-threaded apartment only if the thread doesn't have an apartment-threaded one.

Alexandre Julliard julliard at winehq.org
Fri Aug 6 16:10:40 CDT 2021


Module: wine
Branch: master
Commit: b4da14035741f287130002b512c7d0e9117da80a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b4da14035741f287130002b512c7d0e9117da80a

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Thu Jul 29 19:18:27 2021 +0300

combase: When looking up an apartment which has a given creator thread ID use multi-threaded apartment only if the thread doesn't have an apartment-threaded one.

CoIncrementMTAUsage() always creates the MTA if it doesn't already exist,
and mta->tid may accidently match the apt->tid of the apartment-threaded
apartment of the thread.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/combase/apartment.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/dlls/combase/apartment.c b/dlls/combase/apartment.c
index 108d6a71c5c..690bc69db1b 100644
--- a/dlls/combase/apartment.c
+++ b/dlls/combase/apartment.c
@@ -663,13 +663,20 @@ struct apartment * apartment_findfromtid(DWORD tid)
     EnterCriticalSection(&apt_cs);
     LIST_FOR_EACH_ENTRY(apt, &apts, struct apartment, entry)
     {
-        if (apt->tid == tid)
+        if (apt != mta && apt->tid == tid)
         {
             result = apt;
             apartment_addref(result);
             break;
         }
     }
+
+    if (!result && mta && mta->tid == tid)
+    {
+        result = mta;
+        apartment_addref(result);
+    }
+
     LeaveCriticalSection(&apt_cs);
 
     return result;




More information about the wine-cvs mailing list