Issue #2686 - Don't rely on return value of ExecutionContext::Compile when the context may forbid running scripts

This is relevant if scripting is terminated due to execution timeout but there are setTimeout/Interval callbacks pending
or if scripting is disabled altogether.
This commit is contained in:
Martok 2025-01-26 21:46:31 +01:00 committed by roytam1
commit 0590764f1f
4 changed files with 12 additions and 8 deletions

View file

@ -2377,10 +2377,7 @@ ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest)
rv = exec.Compile(options, srcBuf);
}
if (rv == NS_OK) {
JS::Rooted<JSScript*> script(cx);
script = exec.GetScript();
// With scripts disabled GetScript() will return nullptr
JS::Rooted<JSScript*> script(cx, exec.GetScript());
if (script) {
// Create a ClassicScript object and associate it with the
// JSScript.