Bug 1448612: Don't take ownership of the stream data too early. r=baku
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 25 Mar 2018 05:02:16 +0200
changeset 410348 54b5c168cc34fb0f8793fcca70174b8effb3d734
parent 410347 82b0578b5b133e16fd0aa3cabf5f9e14d099d373
child 410349 5cf87a14afb5ecb5e9b38608312a9a32d4edaa84
push id33725
push usercsabou@mozilla.com
push dateWed, 28 Mar 2018 09:50:28 +0000
treeherdermozilla-central@5bf126434fac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1448612
milestone61.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 1448612: Don't take ownership of the stream data too early. r=baku MozReview-Commit-ID: F3FRoh3tR9g
dom/fetch/FetchConsumer.cpp
--- a/dom/fetch/FetchConsumer.cpp
+++ b/dom/fetch/FetchConsumer.cpp
@@ -82,23 +82,21 @@ public:
 // thread when already shutting down.
 template <class Derived>
 class AbortConsumeBodyControlRunnable final : public MainThreadWorkerControlRunnable
 {
   RefPtr<FetchBodyConsumer<Derived>> mFetchBodyConsumer;
 
 public:
   AbortConsumeBodyControlRunnable(FetchBodyConsumer<Derived>* aFetchBodyConsumer,
-                                  WorkerPrivate* aWorkerPrivate,
-                                  uint8_t* aResult)
+                                  WorkerPrivate* aWorkerPrivate)
     : MainThreadWorkerControlRunnable(aWorkerPrivate)
     , mFetchBodyConsumer(aFetchBodyConsumer)
   {
     MOZ_ASSERT(NS_IsMainThread());
-    free(aResult);
   }
 
   bool
   WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
   {
     mFetchBodyConsumer->ContinueConsumeBody(NS_BINDING_ABORTED, 0, nullptr,
                                             true /* shutting down */);
     return true;
@@ -126,18 +124,17 @@ public:
     if (!mBodyConsumer) {
       return;
     }
 
     // Web Worker
     if (mWorkerRef) {
       RefPtr<AbortConsumeBodyControlRunnable<Derived>> r =
         new AbortConsumeBodyControlRunnable<Derived>(mBodyConsumer,
-                                                     mWorkerRef->Private(),
-                                                     nullptr);
+                                                     mWorkerRef->Private());
       if (!r->Dispatch()) {
         MOZ_CRASH("We are going to leak");
       }
       return;
     }
 
     // Main-thread
     mBodyConsumer->ContinueConsumeBody(NS_ERROR_FAILURE, 0, nullptr);
@@ -259,24 +256,23 @@ public:
       }
     }
 
     // The worker is shutting down. Let's use a control runnable to complete the
     // shutting down procedure.
 
     RefPtr<AbortConsumeBodyControlRunnable<Derived>> r =
       new AbortConsumeBodyControlRunnable<Derived>(mFetchBodyConsumer,
-                                                   mWorkerRef->Private(),
-                                                   nonconstResult);
+                                                   mWorkerRef->Private());
     if (NS_WARN_IF(!r->Dispatch())) {
       return NS_ERROR_FAILURE;
     }
 
-    // FetchBody is responsible for data.
-    return NS_SUCCESS_ADOPTED_DATA;
+    // We haven't taken ownership of the data.
+    return NS_OK;
   }
 
   virtual void BlobStoreCompleted(MutableBlobStorage* aBlobStorage,
                                   Blob* aBlob,
                                   nsresult aRv) override
   {
     // On error.
     if (NS_FAILED(aRv)) {