summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Smith <brian@dbsoft.org>2023-05-21 07:55:37 -0500
committerBrian Smith <brian@dbsoft.org>2023-05-21 07:55:37 -0500
commitbeabbde7062779371f0349c742c7954099fa80f3 (patch)
tree49ddadf92ad9e546d54ed688d503f46c6f822395
parente4eb31879fd84a3bc83f2a89e9084e140e715c9b (diff)
downloaduxp-beabbde7062779371f0349c742c7954099fa80f3.tar.gz
Issue #2252 - Prevent crash when attempting to load a script with execution disallowed.
This issue is due to the ExecutionContext added in Issue #1691 not handling GetScript() in a context where script execution is not allowed. This expressed itself in crashes when playing MP4s with the NoScript extension installed and enabled.
-rw-r--r--dom/script/ScriptLoader.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp
index 523e34af42..293e1014a6 100644
--- a/dom/script/ScriptLoader.cpp
+++ b/dom/script/ScriptLoader.cpp
@@ -2362,11 +2362,14 @@ ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest)
JS::Rooted<JSScript*> script(cx);
script = exec.GetScript();
- // Create a ClassicScript object and associate it with the
- // JSScript.
- RefPtr<ClassicScript> classicScript = new ClassicScript(
- aRequest->mFetchOptions, aRequest->mBaseURL);
- classicScript->AssociateWithScript(script);
+ // With scripts disabled GetScript() will return nullptr
+ if (script) {
+ // Create a ClassicScript object and associate it with the
+ // JSScript.
+ RefPtr<ClassicScript> classicScript = new ClassicScript(
+ aRequest->mFetchOptions, aRequest->mBaseURL);
+ classicScript->AssociateWithScript(script);
+ }
rv = exec.ExecScript();
}