bug 993591 - PSM HTTP Fetch should own streamloader data r=dkeller r=mayhemmer
authorPatrick McManus <mcmanus@ducksong.com>
Wed, 09 Apr 2014 17:48:17 -0400
changeset 198705 800df0af425160dd45f7d9cbf63796b7b6a4c633
parent 198704 993c3b5ff4596e3ac7425c8e723f5eb97bc17c50
child 198706 feded4c79308a7f972aacbec7e0c61d157482b7c
push id486
push userasasaki@mozilla.com
push dateMon, 14 Jul 2014 18:39:42 +0000
treeherdermozilla-release@d33428174ff1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdkeller, mayhemmer
bugs993591
milestone31.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 993591 - PSM HTTP Fetch should own streamloader data r=dkeller r=mayhemmer
security/manager/ssl/src/nsNSSCallbacks.cpp
security/manager/ssl/src/nsNSSCallbacks.h
--- a/security/manager/ssl/src/nsNSSCallbacks.cpp
+++ b/security/manager/ssl/src/nsNSSCallbacks.cpp
@@ -605,16 +605,20 @@ nsHTTPListener::nsHTTPListener()
 {
 }
 
 nsHTTPListener::~nsHTTPListener()
 {
   if (mResponsibleForDoneSignal)
     send_done_signal();
 
+  if (mResultData) {
+    NS_Free(const_cast<uint8_t *>(mResultData));
+  }
+
   if (mLoader) {
     nsCOMPtr<nsIThread> mainThread(do_GetMainThread());
     NS_ProxyRelease(mainThread, mLoader);
   }
 }
 
 NS_IMPL_ISUPPORTS1(nsHTTPListener, nsIStreamLoaderObserver)
 
@@ -673,17 +677,18 @@ nsHTTPListener::OnStreamComplete(nsIStre
 
   if (NS_SUCCEEDED(rv))
   {
     rv = hchan->GetRequestSucceeded(&mHttpRequestSucceeded);
     if (NS_FAILED(rv))
       mHttpRequestSucceeded = false;
 
     mResultLen = stringLen;
-    mResultData = string; // reference. Make sure loader lives as long as this
+    mResultData = string; // take ownership of allocation
+    aStatus = NS_SUCCESS_ADOPTED_DATA;
 
     unsigned int rcode;
     rv = hchan->GetResponseStatus(&rcode);
     if (NS_FAILED(rv))
       mHttpResponseCode = 500;
     else
       mHttpResponseCode = rcode;
 
--- a/security/manager/ssl/src/nsNSSCallbacks.h
+++ b/security/manager/ssl/src/nsNSSCallbacks.h
@@ -44,17 +44,17 @@ public:
   nsCOMPtr<nsIStreamLoader> mLoader;
 
   nsresult mResultCode;
 
   bool mHttpRequestSucceeded;
   uint16_t mHttpResponseCode;
   nsCString mHttpResponseContentType;
 
-  const uint8_t* mResultData; // not owned, refers to mLoader
+  const uint8_t* mResultData; // allocated in loader, but owned by listener
   uint32_t mResultLen;
   
   mozilla::Mutex mLock;
   mozilla::CondVar mCondition;
   volatile bool mWaitFlag;
   
   bool mResponsibleForDoneSignal;
   void send_done_signal();