Bug 1514488 - Check if IPC still opens before sending classify result. r=baku

The crash happens when parent process tries to send classify result to
the content process while the IPC connection is already closed.

The only case that we needs IPC for classification is for Flash classification, but flash
classification is moved to parent process after Bug 1514202.

Although right now there is no consumer for the IPC version of
nsUrlClassifierDBService::AsyncClassifyLocalWithFeatures, we should
still fix this bug.

Differential Revision: https://phabricator.services.mozilla.com/D16362

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dimi Lee 2019-01-14 08:24:39 +00:00
parent 24d3ea5ce2
commit 53158f3fcb

View File

@ -161,6 +161,7 @@ mozilla::ipc::IPCResult URLClassifierLocalParent::StartClassify(
NS_IMETHODIMP NS_IMETHODIMP
URLClassifierLocalParent::OnClassifyComplete( URLClassifierLocalParent::OnClassifyComplete(
const nsTArray<RefPtr<nsIUrlClassifierFeatureResult>>& aResults) { const nsTArray<RefPtr<nsIUrlClassifierFeatureResult>>& aResults) {
if (mIPCOpen) {
nsTArray<URLClassifierLocalResult> ipcResults; nsTArray<URLClassifierLocalResult> ipcResults;
for (nsIUrlClassifierFeatureResult* result : aResults) { for (nsIUrlClassifierFeatureResult* result : aResults) {
URLClassifierLocalResult* ipcResult = ipcResults.AppendElement(); URLClassifierLocalResult* ipcResult = ipcResults.AppendElement();
@ -174,5 +175,6 @@ URLClassifierLocalParent::OnClassifyComplete(
} }
Unused << Send__delete__(this, ipcResults); Unused << Send__delete__(this, ipcResults);
}
return NS_OK; return NS_OK;
} }