Bug 1873874 - Fixed crash due to empty mTargetURI when calling Predictor::Action::OnCacheEntryAvailable, r=necko-reviewers,kershaw

There was a bug where the Action was getting initialized with the wrong URI, thus mTargerURI staying empty.
Also added an errorcheck to OnCacheEntryAvailable so even if an empty URI sneaks in from somewhere else it doesn't just crash.

Differential Revision: https://phabricator.services.mozilla.com/D225181
This commit is contained in:
Oskar Mansfeld
2024-10-17 08:39:40 +00:00
parent ba8fe642df
commit 53b093b51a

View File

@@ -181,6 +181,9 @@ Predictor::Action::OnCacheEntryAvailable(nsICacheEntry* entry, bool isNew,
MOZ_ASSERT(NS_IsMainThread(), "Got cache entry off main thread!");
nsAutoCString targetURI, sourceURI;
if (!mTargetURI) {
return NS_ERROR_UNEXPECTED;
}
mTargetURI->GetAsciiSpec(targetURI);
if (mSourceURI) {
mSourceURI->GetAsciiSpec(sourceURI);
@@ -571,7 +574,7 @@ Predictor::PredictNative(nsIURI* targetURI, nsIURI* sourceURI,
// waiting on the less-important predictor-only cache entry
RefPtr<Predictor::Action> uriAction = new Predictor::Action(
Predictor::Action::IS_FULL_URI, Predictor::Action::DO_PREDICT, argReason,
targetURI, nullptr, verifier, this);
uriKey, nullptr, verifier, this);
nsAutoCString uriKeyStr;
uriKey->GetAsciiSpec(uriKeyStr);
PREDICTOR_LOG((" Predict uri=%s reason=%d action=%p", uriKeyStr.get(),