mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1329669 Gracefully handle nullptr Cache actor in CacheStorage::Open() result. r=asuth
This commit is contained in:
parent
7254b4bfa4
commit
076e2cbd26
@ -100,3 +100,4 @@ MSG_DEF(MSG_TIME_VALUE_OUT_OF_RANGE, 1, JSEXN_TYPEERR, "{0} is outside the suppo
|
||||
MSG_DEF(MSG_ONLY_IF_CACHED_WITHOUT_SAME_ORIGIN, 1, JSEXN_TYPEERR, "Request mode '{0}' was used, but request cache mode 'only-if-cached' can only be used with request mode 'same-origin'.")
|
||||
MSG_DEF(MSG_THRESHOLD_RANGE_ERROR, 0, JSEXN_RANGEERR, "Threshold values must all be in the range [0, 1].")
|
||||
MSG_DEF(MSG_WORKER_THREAD_SHUTTING_DOWN, 0, JSEXN_TYPEERR, "The Worker thread is shutting down.")
|
||||
MSG_DEF(MSG_CACHE_OPEN_FAILED, 0, JSEXN_TYPEERR, "CacheStorage.open() failed to access the storage system.")
|
||||
|
11
dom/cache/CacheOpChild.cpp
vendored
11
dom/cache/CacheOpChild.cpp
vendored
@ -155,6 +155,17 @@ CacheOpChild::Recv__delete__(const ErrorResult& aRv,
|
||||
{
|
||||
auto actor = static_cast<CacheChild*>(
|
||||
aResult.get_StorageOpenResult().actorChild());
|
||||
|
||||
// If we have a success status then we should have an actor. Gracefully
|
||||
// reject instead of crashing, though, if we get a nullptr here.
|
||||
MOZ_DIAGNOSTIC_ASSERT(actor);
|
||||
if (!actor) {
|
||||
ErrorResult status;
|
||||
status.ThrowTypeError<MSG_CACHE_OPEN_FAILED>();
|
||||
mPromise->MaybeReject(status);
|
||||
break;
|
||||
}
|
||||
|
||||
actor->SetWorkerHolder(GetWorkerHolder());
|
||||
RefPtr<Cache> cache = new Cache(mGlobal, actor);
|
||||
mPromise->MaybeResolve(cache);
|
||||
|
3
dom/cache/Manager.cpp
vendored
3
dom/cache/Manager.cpp
vendored
@ -1215,6 +1215,7 @@ public:
|
||||
&cacheFound, &mCacheId);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
if (cacheFound) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(mCacheId != INVALID_CACHE_ID);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -1227,12 +1228,14 @@ public:
|
||||
rv = trans.Commit();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
MOZ_DIAGNOSTIC_ASSERT(mCacheId != INVALID_CACHE_ID);
|
||||
return rv;
|
||||
}
|
||||
|
||||
virtual void
|
||||
Complete(Listener* aListener, ErrorResult&& aRv) override
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(aRv.Failed() || mCacheId != INVALID_CACHE_ID);
|
||||
aListener->OnOpComplete(Move(aRv), StorageOpenResult(), mCacheId);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user