summaryrefslogtreecommitdiffstats
path: root/dom/fetch
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-10-21 20:35:07 +0000
committerMoonchild <moonchild@palemoon.org>2020-10-24 10:38:07 +0000
commitc3778db14df34e88bfd3663b2b3fb54ead633402 (patch)
tree818c162ad8171ce66eb3e4f0c0ef5abde8fbe59c /dom/fetch
parentabcee4f85c5320ceab1f16712d26ea059ef67fd9 (diff)
downloadUXP-c3778db14df34e88bfd3663b2b3fb54ead633402.tar
UXP-c3778db14df34e88bfd3663b2b3fb54ead633402.tar.gz
UXP-c3778db14df34e88bfd3663b2b3fb54ead633402.tar.lz
UXP-c3778db14df34e88bfd3663b2b3fb54ead633402.tar.xz
UXP-c3778db14df34e88bfd3663b2b3fb54ead633402.zip
[DOM Fetch] Improve stability of Fetch API.
Diffstat (limited to 'dom/fetch')
-rw-r--r--dom/fetch/FetchDriver.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/dom/fetch/FetchDriver.cpp b/dom/fetch/FetchDriver.cpp
index fd1e99a2b..d028ffdba 100644
--- a/dom/fetch/FetchDriver.cpp
+++ b/dom/fetch/FetchDriver.cpp
@@ -709,10 +709,12 @@ FetchDriver::OnDataAvailable(nsIRequest* aRequest,
// about races.
if (mObserver) {
+ // Need to keep mObserver alive.
+ RefPtr<FetchDriverObserver> observer = mObserver;
if (NS_IsMainThread()) {
- mObserver->OnDataAvailable();
+ observer->OnDataAvailable();
} else {
- RefPtr<Runnable> runnable = new DataAvailableRunnable(mObserver);
+ RefPtr<Runnable> runnable = new DataAvailableRunnable(observer);
nsresult rv = NS_DispatchToMainThread(runnable);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@@ -720,12 +722,15 @@ FetchDriver::OnDataAvailable(nsIRequest* aRequest,
}
}
- uint32_t aRead;
+ // Explicitly initialized to 0 because in some cases nsStringInputStream may
+ // not write to aRead.
+ uint32_t aRead = 0;
MOZ_ASSERT(mResponse);
MOZ_ASSERT(mPipeOutputStream);
// From "Main Fetch" step 17: SRI-part2.
- if (mResponse->Type() != ResponseType::Error &&
+ if (mResponse &&
+ mResponse->Type() != ResponseType::Error &&
!mRequest->GetIntegrity().IsEmpty()) {
MOZ_ASSERT(mSRIDataVerifier);