From 6016e244fa91e343b96ac0e33aac533c4e8682a4 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 30 Mar 2021 14:53:40 -0700 Subject: [PATCH] fix: handle an unparsable pdf manifest (#28432) --- .../extensions/electron_extension_system.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/shell/browser/extensions/electron_extension_system.cc b/shell/browser/extensions/electron_extension_system.cc index 20ffcc552ee6..3abd46744fc7 100644 --- a/shell/browser/extensions/electron_extension_system.cc +++ b/shell/browser/extensions/electron_extension_system.cc @@ -114,13 +114,16 @@ void ElectronExtensionSystem::LoadComponentExtensions() { std::string pdf_manifest_string = pdf_extension_util::GetManifest(); std::unique_ptr pdf_manifest = ParseManifest(pdf_manifest_string); - base::FilePath root_directory; - CHECK(base::PathService::Get(chrome::DIR_RESOURCES, &root_directory)); - root_directory = root_directory.Append(FILE_PATH_LITERAL("pdf")); - scoped_refptr pdf_extension = extensions::Extension::Create( - root_directory, extensions::Manifest::COMPONENT, *pdf_manifest, - extensions::Extension::REQUIRE_KEY, &utf8_error); - extension_loader_->registrar()->AddExtension(pdf_extension); + if (pdf_manifest) { + base::FilePath root_directory; + CHECK(base::PathService::Get(chrome::DIR_RESOURCES, &root_directory)); + root_directory = root_directory.Append(FILE_PATH_LITERAL("pdf")); + scoped_refptr pdf_extension = + extensions::Extension::Create( + root_directory, extensions::Manifest::COMPONENT, *pdf_manifest, + extensions::Extension::REQUIRE_KEY, &utf8_error); + extension_loader_->registrar()->AddExtension(pdf_extension); + } #endif }