Bug 744836: Adds null checks for mEventTarget in nsTimerImpl. r=bsmedberg
authorAaron Klotz <aklotz@mozilla.com>
Tue, 23 Apr 2013 11:24:20 -0600
changeset 140602 f8077e8edd44d68177aa90d969733562d916de4c
parent 140601 42f859a219d647f6bc5b297add90ca31ae59a737
child 140603 950e522a79379e20e58997a7a50d3126db9ee885
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs744836
milestone23.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 744836: Adds null checks for mEventTarget in nsTimerImpl. r=bsmedberg
xpcom/threads/nsTimerImpl.cpp
--- a/xpcom/threads/nsTimerImpl.cpp
+++ b/xpcom/threads/nsTimerImpl.cpp
@@ -314,16 +314,20 @@ void nsTimerImpl::Shutdown()
 }
 
 
 nsresult nsTimerImpl::InitCommon(uint32_t aType, uint32_t aDelay)
 {
   nsresult rv;
 
   NS_ENSURE_TRUE(gThread, NS_ERROR_NOT_INITIALIZED);
+  if (!mEventTarget) {
+    NS_ERROR("mEventTarget is NULL");
+    return NS_ERROR_NOT_INITIALIZED;
+  }
 
   rv = gThread->Init();
   NS_ENSURE_SUCCESS(rv, rv);
 
   /**
    * In case of re-Init, both with and without a preceding Cancel, clear the
    * mCanceled flag and assign a new mGeneration.  But first, remove any armed
    * timer from the timer thread's list.
@@ -629,16 +633,21 @@ NS_IMETHODIMP nsTimerEvent::Run()
 
   timer->Fire();
 
   return NS_OK;
 }
 
 nsresult nsTimerImpl::PostTimerEvent()
 {
+  if (!mEventTarget) {
+    NS_ERROR("Attempt to post timer event to NULL event target");
+    return NS_ERROR_NOT_INITIALIZED;
+  }
+
   // XXX we may want to reuse this nsTimerEvent in the case of repeating timers.
 
   // Since TimerThread addref'd 'this' for us, we don't need to addref here.
   // We will release in destroyMyEvent.  We need to copy the generation number
   // from this timer into the event, so we can avoid firing a timer that was
   // re-initialized after being canceled.
 
   nsRefPtr<nsTimerEvent> event = new nsTimerEvent(this, mGeneration);