mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: crash on extension unload when script validation finishes (#41702)
https://chromium-review.googlesource.com/c/chromium/src/+/5225796 Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "extensions/browser/api/scripting/scripting_utils.h"
|
||||
#include "extensions/browser/extension_api_frame_id_map.h"
|
||||
#include "extensions/browser/extension_file_task_runner.h"
|
||||
#include "extensions/browser/extension_registry.h"
|
||||
#include "extensions/browser/extension_system.h"
|
||||
#include "extensions/browser/extension_user_script_loader.h"
|
||||
#include "extensions/browser/extension_util.h"
|
||||
@@ -1061,6 +1062,17 @@ void ScriptingRegisterContentScriptsFunction::OnContentScriptFilesValidated(
|
||||
return;
|
||||
}
|
||||
|
||||
// We cannot proceed if the extension is uninstalled or unloaded in the middle
|
||||
// of validating its script files.
|
||||
ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context());
|
||||
if (!extension() ||
|
||||
!registry->enabled_extensions().Contains(extension_id())) {
|
||||
// Note: a Respond() is not needed if the system is shutting down or if the
|
||||
// extension is no longer enabled.
|
||||
Release(); // Matches the `AddRef()` in `Run()`.
|
||||
return;
|
||||
}
|
||||
|
||||
auto error = std::move(result.second);
|
||||
auto scripts = std::move(result.first);
|
||||
ExtensionUserScriptLoader* loader =
|
||||
@@ -1306,6 +1318,17 @@ void ScriptingUpdateContentScriptsFunction::OnContentScriptFilesValidated(
|
||||
return;
|
||||
}
|
||||
|
||||
// We cannot proceed if the extension is uninstalled or unloaded in the middle
|
||||
// of validating its script files.
|
||||
ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context());
|
||||
if (!extension() ||
|
||||
!registry->enabled_extensions().Contains(extension_id())) {
|
||||
// Note: a Respond() is not needed if the system is shutting down or if the
|
||||
// extension is no longer enabled.
|
||||
Release(); // Matches the `AddRef()` in `Run()`.
|
||||
return;
|
||||
}
|
||||
|
||||
auto error = std::move(result.second);
|
||||
auto scripts = std::move(result.first);
|
||||
ExtensionUserScriptLoader* loader =
|
||||
|
||||
Reference in New Issue
Block a user