summaryrefslogtreecommitdiffstats
path: root/dom
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-10-21 20:35:07 +0000
committerMoonchild <moonchild@palemoon.org>2020-10-21 20:35:07 +0000
commit3e59623312828f0730bfd46e745567455d56048e (patch)
tree910f0cf007dabcec1b2c1d33cede31e157e1c1d5 /dom
parente8ae76d473088f140c73376d0f0e324559f344c5 (diff)
downloadUXP-3e59623312828f0730bfd46e745567455d56048e.tar
UXP-3e59623312828f0730bfd46e745567455d56048e.tar.gz
UXP-3e59623312828f0730bfd46e745567455d56048e.tar.lz
UXP-3e59623312828f0730bfd46e745567455d56048e.tar.xz
UXP-3e59623312828f0730bfd46e745567455d56048e.zip
[DOM Fetch] Improve stability of Fetch API.
Diffstat (limited to 'dom')
-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 122875bb0..d18db2834 100644
--- a/dom/fetch/FetchDriver.cpp
+++ b/dom/fetch/FetchDriver.cpp
@@ -708,10 +708,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;
@@ -719,12 +721,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);