Bug 1346426 Don't crash if a window is frozen while there is a dummy timer in the list. r=ehsan
authorBen Kelly <ben@wanderview.com>
Mon, 13 Mar 2017 15:26:22 -0400
changeset 347343 2b52802899ae6b4d14481481e0ea37664c48a7d5
parent 347342 533ce084c0d46a7529fd9a37ad99db43bfb206b9
child 347344 6d38ad302429c98115c354d643e81987ecec5d3c
child 347477 950180909fd0e5031a04fcd4cb8f94ff4be72ae6
push id31495
push userkwierso@gmail.com
push dateMon, 13 Mar 2017 23:37:26 +0000
treeherdermozilla-central@6d38ad302429 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1346426
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1346426 Don't crash if a window is frozen while there is a dummy timer in the list. r=ehsan
dom/base/TimeoutManager.cpp
--- a/dom/base/TimeoutManager.cpp
+++ b/dom/base/TimeoutManager.cpp
@@ -1193,18 +1193,26 @@ TimeoutManager::Resume()
 }
 
 void
 TimeoutManager::Freeze()
 {
   MOZ_LOG(gLog, LogLevel::Debug,
           ("Freeze(TimeoutManager=%p)\n", this));
 
+  DebugOnly<bool> _seenDummyTimeout = false;
+
   TimeStamp now = TimeStamp::Now();
   ForEachUnorderedTimeout([&](Timeout* aTimeout) {
+    if (!aTimeout->mWindow) {
+      NS_ASSERTION(!_seenDummyTimeout, "More than one dummy timeout?!");
+      _seenDummyTimeout = true;
+      return;
+    }
+
     // Save the current remaining time for this timeout.  We will
     // re-apply it when the window is Thaw()'d.  This effectively
     // shifts timers to the right as if time does not pass while
     // the window is frozen.
     TimeDuration delta(0);
     if (aTimeout->When() > now) {
       delta = aTimeout->When() - now;
     }