Bug 1229970 Abort script loading start requests if a load has been canceled. r=khuey a=ritu
authorBen Kelly <ben@wanderview.com>
Wed, 16 Dec 2015 11:31:09 -0800
changeset 305821 6411e85ba1ebf9296b4f0f6bf0451a59070c433a
parent 305820 d5e55b4e6a5b4c21525adb419a31f7ed453fd8a1
child 305822 dac8f420fa9f2a33c8b15ac8775e2f783cd47689
child 305824 1fccaff6574dd52f1196f899ae3367ae889971d7
child 305825 09858825e9b61e3699df24b700374d13cc221876
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey, ritu
bugs1229970
milestone44.0
Bug 1229970 Abort script loading start requests if a load has been canceled. r=khuey a=ritu CLOSED TREE
dom/workers/ScriptLoader.cpp
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -595,16 +595,22 @@ private:
     return NS_OK;
   }
 
   NS_IMETHOD
   OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) override
   {
     AssertIsOnMainThread();
 
+    // If one load info cancels or hits an error, it can race with the start
+    // callback coming from another load info.
+    if (mCanceledMainThread || !mCacheCreator) {
+      return NS_ERROR_FAILURE;
+    }
+
     nsCOMPtr<nsISupportsPRUint32> indexSupports(do_QueryInterface(aContext));
     MOZ_ASSERT(indexSupports, "This should never fail!");
 
     uint32_t index = UINT32_MAX;
     if (NS_FAILED(indexSupports->GetData(&index)) ||
         index >= mLoadInfos.Length()) {
       MOZ_CRASH("Bad index!");
     }