Bug 662554 - Make websocketestablishedconnection getinterface and close() check mOwner != nsnull r=biesi
authorPatrick McManus <mcmanus@ducksong.com>
Wed, 08 Jun 2011 08:27:11 -0400
changeset 71242 b9354cf9282d8b4f8fae3bf43144e3bcf0e6c592
parent 71241 6031f209f2dfab13884d80b64444d07eae447eca
child 71243 452c49cd23c97942a22967599e26611ffd18717d
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)
reviewersbiesi
bugs662554
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 662554 - Make websocketestablishedconnection getinterface and close() check mOwner != nsnull r=biesi
content/base/src/nsWebSocket.cpp
--- a/content/base/src/nsWebSocket.cpp
+++ b/content/base/src/nsWebSocket.cpp
@@ -309,16 +309,17 @@ nsWebSocketEstablishedConnection::Init(n
 
 nsresult
 nsWebSocketEstablishedConnection::PrintErrorOnConsole(const char *aBundleURI,
                                                       const PRUnichar *aError,
                                                       const PRUnichar **aFormatStrings,
                                                       PRUint32 aFormatStringsLen)
 {
   NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
+  NS_ABORT_IF_FALSE(mOwner, "No owner");
 
   nsresult rv;
 
   nsCOMPtr<nsIStringBundleService> bundleService =
     do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIStringBundle> strBundle;
@@ -360,16 +361,18 @@ nsWebSocketEstablishedConnection::PrintE
   return NS_OK;
 }
 
 // when this is called the browser side wants no more part of it
 nsresult
 nsWebSocketEstablishedConnection::Close()
 {
   NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
+  if (!mOwner)
+    return NS_OK;
 
   // Disconnect() can release this object, so we keep a
   // reference until the end of the method
   nsRefPtr<nsWebSocketEstablishedConnection> kungfuDeathGrip = this;
 
   if (mOwner->mReadyState == nsIWebSocket::CONNECTING) {
     mOwner->SetReadyState(nsIWebSocket::CLOSING);
     mOwner->SetReadyState(nsIWebSocket::CLOSED);
@@ -453,16 +456,18 @@ nsWebSocketEstablishedConnection::Discon
   nsLayoutStatics::Release();
   return NS_OK;
 }
 
 nsresult
 nsWebSocketEstablishedConnection::UpdateMustKeepAlive()
 {
   NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
+  NS_ABORT_IF_FALSE(mOwner, "No owner");
+
   mOwner->UpdateMustKeepAlive();
   return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 // nsWebSocketEstablishedConnection::nsIWebSocketListener methods:
 //-----------------------------------------------------------------------------
 
@@ -567,16 +572,19 @@ nsWebSocketEstablishedConnection::OnServ
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 nsWebSocketEstablishedConnection::GetInterface(const nsIID &aIID,
                                                void **aResult)
 {
   NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
 
+  if (!mOwner)
+    return NS_ERROR_FAILURE;
+
   if (aIID.Equals(NS_GET_IID(nsIAuthPrompt)) ||
       aIID.Equals(NS_GET_IID(nsIAuthPrompt2))) {
     nsresult rv;
 
     nsCOMPtr<nsIDocument> doc =
       nsContentUtils::GetDocumentFromScriptContext(mOwner->mScriptContext);
 
     if (!doc) {