mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
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:
parent
f66e96f7e9
commit
76cef3b73d
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -81,7 +81,7 @@ private:
|
||||
, mTargetInterface(aTargetInterface)
|
||||
{}
|
||||
IID mIID;
|
||||
IUnknown* mInterceptor;
|
||||
RefPtr<IUnknown> mInterceptor;
|
||||
IUnknown* mTargetInterface;
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user