Bug 1322460 - Don't addref/release on the return value of prohibited functions. r=aklotz,Ehsan

MozReview-Commit-ID: B0mAMZp5sll

--HG--
extra : rebase_source : fb5e25352089e26172189b9c4f2be8c5553fa5a8
This commit is contained in:
Ting-Yu Chou 2016-12-14 14:34:26 +08:00
parent f66e96f7e9
commit 76cef3b73d
8 changed files with 18 additions and 22 deletions

View File

@ -56,8 +56,8 @@ uiaRawElmProvider::GetIAccessiblePair(__RPC__deref_out_opt IAccessible** aAcc,
return CO_E_OBJNOTCONNECTED;
*aIdChild = CHILDID_SELF;
*aAcc = mAcc;
mAcc->AddRef();
RefPtr<AccessibleWrap> copy(mAcc);
copy.forget(aAcc);
return S_OK;

View File

@ -173,7 +173,7 @@ MemoryDIBTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
// The host will release this ref when it receives the surface descriptor.
// We AddRef in case we die before the host receives the pointer.
aOutDescriptor = SurfaceDescriptorDIB(reinterpret_cast<uintptr_t>(mSurface.get()));
mSurface->AddRef();
mSurface.get()->AddRef();
return true;
}

View File

@ -647,7 +647,7 @@ D3D9TextureData::Unlock()
bool
D3D9TextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
{
mTexture->AddRef(); // Release in TextureHostD3D9::TextureHostD3D9
mTexture.get()->AddRef(); // Release in TextureHostD3D9::TextureHostD3D9
aOutDescriptor = SurfaceDescriptorD3D9(reinterpret_cast<uintptr_t>(mTexture.get()));
return true;
}
@ -835,7 +835,7 @@ TextureHostD3D9::TextureHostD3D9(TextureFlags aFlags,
{
mTexture = reinterpret_cast<IDirect3DTexture9*>(aDescriptor.texture());
MOZ_ASSERT(mTexture);
mTexture->Release(); // see AddRef in TextureClientD3D9::ToSurfaceDescriptor
mTexture.get()->Release(); // see AddRef in TextureClientD3D9::ToSurfaceDescriptor
MOZ_ASSERT(mTexture);
D3DSURFACE_DESC desc;
HRESULT hr = mTexture->GetLevelDesc(0, &desc);

View File

@ -100,8 +100,8 @@ DispatchForwarder::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
// ITypeInfo as implemented by COM is apartment-neutral, so we don't need
// to wrap it (yay!)
if (mTypeInfo) {
*ppTInfo = mTypeInfo.get();
mTypeInfo->AddRef();
RefPtr<ITypeInfo> copy(mTypeInfo);
copy.forget(ppTInfo);
return S_OK;
}
HRESULT hr = E_UNEXPECTED;

View File

@ -61,7 +61,7 @@ Interceptor::~Interceptor()
MOZ_ASSERT(NS_IsMainThread());
for (uint32_t index = 0, len = mInterceptorMap.Length(); index < len; ++index) {
MapEntry& entry = mInterceptorMap[index];
entry.mInterceptor->Release();
entry.mInterceptor = nullptr;
entry.mTargetInterface->Release();
}
}
@ -234,12 +234,9 @@ Interceptor::GetInterceptorForIID(REFIID aIid, void** aOutInterceptor)
if (entry && entry->mInterceptor) {
unkInterceptor = entry->mInterceptor;
} else {
// We're inserting unkInterceptor into the map but we still want to hang
// onto it locally so that we can QI it below.
unkInterceptor->AddRef();
// OTOH we must not touch the refcount for the target interface
// because we are just moving it into the map and its refcounting might
// not be thread-safe.
// MapEntry has a RefPtr to unkInterceptor, OTOH we must not touch the
// refcount for the target interface because we are just moving it into
// the map and its refcounting might not be thread-safe.
IUnknown* rawTargetInterface = targetInterface.release();
mInterceptorMap.AppendElement(MapEntry(aIid,
unkInterceptor,

View File

@ -81,7 +81,7 @@ private:
, mTargetInterface(aTargetInterface)
{}
IID mIID;
IUnknown* mInterceptor;
RefPtr<IUnknown> mInterceptor;
IUnknown* mTargetInterface;
};

View File

@ -99,7 +99,7 @@ WeakReferenceSupport::ClearWeakRefs()
{
for (uint32_t i = 0, len = mWeakRefs.Length(); i < len; ++i) {
mWeakRefs[i]->Clear();
mWeakRefs[i]->Release();
mWeakRefs[i] = nullptr;
}
mWeakRefs.Clear();
}
@ -120,8 +120,7 @@ WeakReferenceSupport::GetWeakReference(IWeakReference** aOutWeakRef)
return hr;
}
mWeakRefs.AppendElement(weakRef.get());
weakRef->AddRef();
mWeakRefs.AppendElement(weakRef);
return S_OK;
}

View File

@ -70,10 +70,10 @@ private:
private:
// Using a raw CRITICAL_SECTION here because it can be reentered
CRITICAL_SECTION mCS;
ULONG mRefCnt;
nsTArray<WeakRef*> mWeakRefs;
Flags mFlags;
CRITICAL_SECTION mCS;
ULONG mRefCnt;
nsTArray<RefPtr<WeakRef>> mWeakRefs;
Flags mFlags;
};
class WeakRef : public IWeakReference