Bug 1002014 - Error case leak in AsmJSCache.cpp AllocEntryParent(); r=luke

This commit is contained in:
Jan Varga 2014-05-07 16:32:02 +02:00
parent d4400ed747
commit b797941923

View File

@ -1323,23 +1323,22 @@ AllocEntryParent(OpenMode aOpenMode,
WriteParams aWriteParams,
nsIPrincipal* aPrincipal)
{
ParentProcessRunnable* runnable =
nsRefPtr<ParentProcessRunnable> runnable =
new ParentProcessRunnable(aPrincipal, aOpenMode, aWriteParams);
// AddRef to keep the runnable alive until DeallocEntryParent.
runnable->AddRef();
nsresult rv = NS_DispatchToMainThread(runnable);
NS_ENSURE_SUCCESS(rv, nullptr);
return runnable;
// Transfer ownership to IPDL.
return runnable.forget().take();
}
void
DeallocEntryParent(PAsmJSCacheEntryParent* aActor)
{
// Match the AddRef in AllocEntryParent.
static_cast<ParentProcessRunnable*>(aActor)->Release();
// Transfer ownership back from IPDL.
nsRefPtr<ParentProcessRunnable> op =
dont_AddRef(static_cast<ParentProcessRunnable*>(aActor));
}
namespace {