Bug 940724 - Move XMLHttpRequest off of the stack to silence analysis, r=bent
authorSteve Fink <sfink@mozilla.com>
Tue, 19 Nov 2013 15:27:00 -0800
changeset 156635 972924aa711072a0bd6ee233fd242d3245d2a110
parent 156634 4088133a80e698e2a15502b4978ffd6f1a3b0a01
child 156636 ab8b9448e062b898cb5542f80d283e8ef1040b25
push id25684
push usercbook@mozilla.com
push dateThu, 21 Nov 2013 13:21:05 +0000
treeherdermozilla-central@7427eede548f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs940724
milestone28.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 940724 - Move XMLHttpRequest off of the stack to silence analysis, r=bent
dom/workers/XMLHttpRequest.cpp
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -677,29 +677,29 @@ public:
       }
       else {
         mProxy->mLastLengthComputable = mLengthComputable;
         mProxy->mLastLoaded = mLoaded;
         mProxy->mLastTotal = mTotal;
       }
     }
 
-    XMLHttpRequest::StateData state;
-    StateDataAutoRooter rooter(aCx, &state);
+    nsAutoPtr<XMLHttpRequest::StateData> state(new XMLHttpRequest::StateData());
+    StateDataAutoRooter rooter(aCx, state);
 
-    state.mResponseTextResult = mResponseTextResult;
-    state.mResponseText = mResponseText;
+    state->mResponseTextResult = mResponseTextResult;
+    state->mResponseText = mResponseText;
 
     if (NS_SUCCEEDED(mResponseTextResult)) {
       MOZ_ASSERT(JSVAL_IS_VOID(mResponse) || JSVAL_IS_NULL(mResponse));
-      state.mResponseResult = mResponseTextResult;
-      state.mResponse = mResponse;
+      state->mResponseResult = mResponseTextResult;
+      state->mResponse = mResponse;
     }
     else {
-      state.mResponseResult = mResponseResult;
+      state->mResponseResult = mResponseResult;
 
       if (NS_SUCCEEDED(mResponseResult)) {
         if (mResponseBuffer.data()) {
           MOZ_ASSERT(JSVAL_IS_VOID(mResponse));
 
           JSAutoStructuredCloneBuffer responseBuffer;
           mResponseBuffer.swap(responseBuffer);
 
@@ -711,33 +711,33 @@ public:
           nsTArray<nsCOMPtr<nsISupports> > clonedObjects;
           clonedObjects.SwapElements(mClonedObjects);
 
           JS::Rooted<JS::Value> response(aCx);
           if (!responseBuffer.read(aCx, &response, callbacks, &clonedObjects)) {
             return false;
           }
 
-          state.mResponse = response;
+          state->mResponse = response;
         }
         else {
-          state.mResponse = mResponse;
+          state->mResponse = mResponse;
         }
       }
     }
 
-    state.mStatusResult = mStatusResult;
-    state.mStatus = mStatus;
+    state->mStatusResult = mStatusResult;
+    state->mStatus = mStatus;
 
-    state.mStatusText = mStatusText;
+    state->mStatusText = mStatusText;
 
-    state.mReadyState = mReadyState;
+    state->mReadyState = mReadyState;
 
     XMLHttpRequest* xhr = mProxy->mXMLHttpRequestPrivate;
-    xhr->UpdateState(state);
+    xhr->UpdateState(*state);
 
     if (mUploadEvent && !xhr->GetUploadObjectNoCreate()) {
       return true;
     }
 
     JS::Rooted<JSString*> type(aCx, JS_NewUCStringCopyN(aCx, mType.get(), mType.Length()));
     if (!type) {
       return false;