Bug 1339617 - move GetClosure call prior to canceling timer; r=mayhemer

Some recent work on timers changed how we handle callbacks and
associated closure data: prior to these changes, canceling timers would
not null out associated closure data, so calling GetClosure() on a timer
after canceling it would return what you had put in.  After these
changes, however, GetClosure() after cancellation would retrieve a null
value, causing anything that assumed non-nullness to crash.  The simple
fix is to move the GetClosure() call prior to Cancel()'ing the timer.
This commit is contained in:
Nathan Froyd 2017-02-21 13:35:52 -05:00
Родитель 13a46e3d87
Коммит 2f23818440
1 изменённых файлов: 1 добавлений и 1 удалений

2
netwerk/cache/nsDeleteDir.cpp поставляемый
Просмотреть файл

@ -80,10 +80,10 @@ nsDeleteDir::Shutdown(bool finishDeleting)
for (int32_t i = gInstance->mTimers.Count(); i > 0; i--) {
nsCOMPtr<nsITimer> timer = gInstance->mTimers[i-1];
gInstance->mTimers.RemoveObjectAt(i-1);
timer->Cancel();
nsCOMArray<nsIFile> *arg;
timer->GetClosure((reinterpret_cast<void**>(&arg)));
timer->Cancel();
if (finishDeleting)
dirsToRemove.AppendObjects(*arg);