Bug 976537 - Guard against crashing in NFC shutdown when sNfcConsumer is NULL. r=allstars.chh
authorDouglas Crosher <dtc-moz@scieneer.com>
Wed, 26 Feb 2014 00:54:54 +1100
changeset 171363 34dd2345385545b9d805ca7577bb8e7cd4b0c5db
parent 171317 dcfcbdb6f2bbd1297efbe3244a3ed85856f1c359
child 171364 dfecceda4db8fdeb35dd9fa7712e3307e5695bce
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersallstars
bugs976537
milestone30.0a1
Bug 976537 - Guard against crashing in NFC shutdown when sNfcConsumer is NULL. r=allstars.chh
ipc/nfc/Nfc.cpp
--- a/ipc/nfc/Nfc.cpp
+++ b/ipc/nfc/Nfc.cpp
@@ -306,19 +306,21 @@ NfcConsumer::Register(WorkerCrossThreadD
     return NS_OK;
 }
 
 void
 NfcConsumer::Shutdown()
 {
     MOZ_ASSERT(NS_IsMainThread());
 
-    sNfcConsumer->mShutdown = true;
-    sNfcConsumer->CloseSocket();
-    sNfcConsumer = nullptr;
+    if (sNfcConsumer) {
+        sNfcConsumer->mShutdown = true;
+        sNfcConsumer->CloseSocket();
+        sNfcConsumer = nullptr;
+    }
 }
 
 void
 NfcConsumer::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
 {
     MOZ_ASSERT(NS_IsMainThread());
 
     nsRefPtr<DispatchNFCEvent> dre(new DispatchNFCEvent(aMessage.forget()));