Bug 917602 - Fix some shutdown crashes r=bent
authorFabrice Desré <fabrice@mozilla.com>
Wed, 18 Sep 2013 10:53:07 -0700
changeset 147763 1fce29969d8df0e8d14dde019a88c650b6d24db6
parent 147762 01a4e5ef9aa7782f591ca599970d7d050ecdc0c0
child 147764 39ae127ad4857cc9015b6cfb850770121bcc6c3a
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbent
bugs917602
milestone27.0a1
Bug 917602 - Fix some shutdown crashes r=bent
hal/gonk/GonkDiskSpaceWatcher.cpp
hal/gonk/GonkHal.cpp
--- a/hal/gonk/GonkDiskSpaceWatcher.cpp
+++ b/hal/gonk/GonkDiskSpaceWatcher.cpp
@@ -128,17 +128,20 @@ private:
 
 // Helper runnable to delete the watcher on the main thread.
 class DiskSpaceCleaner : public nsRunnable
 {
 public:
   NS_IMETHOD Run()
   {
     MOZ_ASSERT(NS_IsMainThread());
-    delete gHalDiskSpaceWatcher;
+    if (gHalDiskSpaceWatcher) {
+      delete gHalDiskSpaceWatcher;
+      gHalDiskSpaceWatcher = nullptr;
+    }
     return NS_OK;
   }
 };
 
 GonkDiskSpaceWatcher::GonkDiskSpaceWatcher() :
   mLastFreeSpace(UINT64_MAX),
   mIsDiskFull(false),
   mFreeSpace(UINT64_MAX),
--- a/hal/gonk/GonkHal.cpp
+++ b/hal/gonk/GonkHal.cpp
@@ -880,17 +880,17 @@ DestroyAlarmData(void* aData)
 {
   AlarmData* alarmData = static_cast<AlarmData*>(aData);
   delete alarmData;
 }
 
 // Runs on alarm-watcher thread.
 void ShutDownAlarm(int aSigno)
 {
-  if (aSigno == SIGUSR1) {
+  if (aSigno == SIGUSR1 && sAlarmData) {
     sAlarmData->mShuttingDown = true;
   }
   return;
 }
 
 static void*
 WaitForAlarm(void* aData)
 {