Bug 1177501 - Hold a strong ref to mThread. r=jya

This commit is contained in:
Bobby Holley 2015-06-25 13:20:04 -07:00
Родитель 2516e68ef2
Коммит 3c748d3d45
1 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -39,7 +39,11 @@ void
MediaTimer::DispatchDestroy()
{
nsCOMPtr<nsIRunnable> task = NS_NewNonOwningRunnableMethod(this, &MediaTimer::Destroy);
nsresult rv = mThread->Dispatch(task, NS_DISPATCH_NORMAL);
// Hold a strong reference to the thread so that it doesn't get deleted in
// Destroy(), which may run completely before the stack if Dispatch() begins
// to unwind.
nsCOMPtr<nsIEventTarget> thread = mThread;
nsresult rv = thread->Dispatch(task, NS_DISPATCH_NORMAL);
MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
(void) rv;
}