From 106de86dc4ec751a6715cd8685b990aeb359f4d0 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Sun, 21 May 2023 07:55:37 -0500 Subject: [PATCH] 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. --- dom/script/ScriptLoader.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index 77bfd2024d..89a74c1541 100644 --- a/dom/script/ScriptLoader.cpp +++ b/dom/script/ScriptLoader.cpp @@ -2363,11 +2363,14 @@ ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest) JS::Rooted script(cx); script = exec.GetScript(); - // Create a ClassicScript object and associate it with the - // JSScript. - RefPtr 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 = new ClassicScript( + aRequest->mFetchOptions, aRequest->mBaseURL); + classicScript->AssociateWithScript(script); + } rv = exec.ExecScript(); }