Bug 663465 - Avoid derefencing null connection pointer when closing a websocket. r=mcmanus
authorJosh Matthews <josh@joshmatthews.net>
Fri, 10 Jun 2011 15:31:47 -0400
changeset 71433 51e2db1a55670b7d9497f22a148a52d5c0fccada
parent 71432 b63b54f27418086d0f8fe103a5882ab4a889e9a5
child 71434 d56a77e8fd753c95a18edd320311107e18a15565
push id159
push usereakhgari@mozilla.com
push dateTue, 16 Aug 2011 17:53:11 +0000
treeherdermozilla-beta@8786e3e49240 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs663465
milestone7.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 663465 - Avoid derefencing null connection pointer when closing a websocket. r=mcmanus
content/base/src/nsWebSocket.cpp
--- a/content/base/src/nsWebSocket.cpp
+++ b/content/base/src/nsWebSocket.cpp
@@ -1295,17 +1295,19 @@ nsWebSocket::Close()
     return NS_OK;
   }
 
   if (mReadyState == nsIWebSocket::CONNECTING) {
     // FailConnection() can release the object, so we keep a reference
     // before calling it
     nsRefPtr<nsWebSocket> kungfuDeathGrip = this;
 
-    mConnection->FailConnection();
+    if (mConnection) {
+      mConnection->FailConnection();
+    }
     return NS_OK;
   }
 
   // mReadyState == nsIWebSocket::OPEN
   mConnection->Close();
 
   return NS_OK;
 }