Extensions: Prevent null dereference in ProcessManager::Observe.
When an extension is unloaded, ExtensionHost::OnExtensionUnloaded nulls its
extension pointer. Hence accessing ExtensionHost::extension() can cause a null
dereference if the extension is being or has been unloaded. This CL changes the
access in ProcessManager::Observe to ExtensionHost::extension_id() hence
preventing a potential null dereference.
BUG=780095
Change-Id: I967c1bf291fa4181d6e00a16156341cf6c3f1a82
Reviewed-on: https://chromium-review.googlesource.com/759681
Commit-Queue: Karan Bhatia <[email protected]>
Reviewed-by: Devlin <[email protected]>
Cr-Commit-Position: refs/heads/master@{#515296}
diff --git a/extensions/browser/extension_host.h b/extensions/browser/extension_host.h
index fea09edc..34812c0 100644
--- a/extensions/browser/extension_host.h
+++ b/extensions/browser/extension_host.h
@@ -53,7 +53,9 @@
const GURL& url, ViewType host_type);
~ExtensionHost() override;
+ // This may be null if the extension has been or is being unloaded.
const Extension* extension() const { return extension_; }
+
const std::string& extension_id() const { return extension_id_; }
content::WebContents* host_contents() const { return host_contents_.get(); }
content::RenderViewHost* render_view_host() const;