Skip to content

Commit e30084f

Browse files
committed
Bug 1489317: Part 4 - Add asssertion that COM is initialized on the thread that is resolving an agile reference; r=mhowell
Depends on D5321 Differential Revision: https://phabricator.services.mozilla.com/D5323 --HG-- extra : moz-landing-system : lando
1 parent 8c9c972 commit e30084f

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

ipc/mscom/AgileReference.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
#include "mozilla/mscom/AgileReference.h"
88

9+
#include "mozilla/Assertions.h"
910
#include "mozilla/DebugOnly.h"
1011
#include "mozilla/DynamicallyLinkedFunctionPtr.h"
11-
#include "mozilla/Assertions.h"
1212
#include "mozilla/Move.h"
13+
#include "mozilla/mscom/Utils.h"
1314

1415
#if NTDDI_VERSION < NTDDI_WINBLUE
1516

@@ -137,6 +138,7 @@ AgileReference::Resolve(REFIID aIid, void** aOutInterface) const
137138
{
138139
MOZ_ASSERT(aOutInterface);
139140
MOZ_ASSERT(mAgileRef || mGitCookie);
141+
MOZ_ASSERT(IsCOMInitializedOnCurrentThread());
140142

141143
if (!aOutInterface) {
142144
return E_INVALIDARG;

ipc/mscom/Utils.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ extern "C" IMAGE_DOS_HEADER __ImageBase;
3232
namespace mozilla {
3333
namespace mscom {
3434

35+
bool
36+
IsCOMInitializedOnCurrentThread()
37+
{
38+
APTTYPE aptType;
39+
APTTYPEQUALIFIER aptTypeQualifier;
40+
HRESULT hr = CoGetApartmentType(&aptType, &aptTypeQualifier);
41+
return hr != CO_E_NOTINITIALIZED;
42+
}
43+
3544
bool
3645
IsCurrentThreadMTA()
3746
{

ipc/mscom/Utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ struct IUnknown;
2020
namespace mozilla {
2121
namespace mscom {
2222

23+
bool IsCOMInitializedOnCurrentThread();
2324
bool IsCurrentThreadMTA();
2425
bool IsProxy(IUnknown* aUnknown);
2526
bool IsValidGUID(REFGUID aCheckGuid);

0 commit comments

Comments
 (0)