Skip to content

Commit 55c7d89

Browse files
committed
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
1 parent 88c4525 commit 55c7d89

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

netwerk/base/Predictor.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ Predictor::Action::OnCacheEntryAvailable(nsICacheEntry* entry, bool isNew,
181181
MOZ_ASSERT(NS_IsMainThread(), "Got cache entry off main thread!");
182182

183183
nsAutoCString targetURI, sourceURI;
184+
if (!mTargetURI) {
185+
return NS_ERROR_UNEXPECTED;
186+
}
184187
mTargetURI->GetAsciiSpec(targetURI);
185188
if (mSourceURI) {
186189
mSourceURI->GetAsciiSpec(sourceURI);
@@ -571,7 +574,7 @@ Predictor::PredictNative(nsIURI* targetURI, nsIURI* sourceURI,
571574
// waiting on the less-important predictor-only cache entry
572575
RefPtr<Predictor::Action> uriAction = new Predictor::Action(
573576
Predictor::Action::IS_FULL_URI, Predictor::Action::DO_PREDICT, argReason,
574-
targetURI, nullptr, verifier, this);
577+
uriKey, nullptr, verifier, this);
575578
nsAutoCString uriKeyStr;
576579
uriKey->GetAsciiSpec(uriKeyStr);
577580
PREDICTOR_LOG((" Predict uri=%s reason=%d action=%p", uriKeyStr.get(),

0 commit comments

Comments
 (0)