mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-18 00:09:44 +00:00
LibWeb: Ensure requests modules is not empty before indexing into it
Regression from 5af613aa65
Fixes: #2676
This commit is contained in:
parent
2ff03ea7d2
commit
30c8510725
Notes:
github-actions[bot]
2024-12-01 14:50:09 +00:00
Author: https://github.com/shannonbooth
Commit: 30c8510725
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2677
Reviewed-by: https://github.com/awesomekling
4 changed files with 64 additions and 47 deletions
|
@ -471,7 +471,9 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. If referrer is a Cyclic Module Record and moduleRequest is equal to the first element of referrer.[[RequestedModules]], then:
|
// 7. If referrer is a Cyclic Module Record and moduleRequest is equal to the first element of referrer.[[RequestedModules]], then:
|
||||||
if (referrer.has<GC::Ref<JS::CyclicModule>>() && module_request == referrer.get<GC::Ref<JS::CyclicModule>>()->requested_modules().first()) {
|
if (referrer.has<GC::Ref<JS::CyclicModule>>()) {
|
||||||
|
// FIXME: Why do we need to check requested modules is empty here?
|
||||||
|
if (auto const& requested_modules = referrer.get<GC::Ref<JS::CyclicModule>>()->requested_modules(); !requested_modules.is_empty() && module_request == requested_modules.first()) {
|
||||||
// 1. For each ModuleRequest record requested of referrer.[[RequestedModules]]:
|
// 1. For each ModuleRequest record requested of referrer.[[RequestedModules]]:
|
||||||
for (auto const& module_request : referrer.get<GC::Ref<JS::CyclicModule>>()->requested_modules()) {
|
for (auto const& module_request : referrer.get<GC::Ref<JS::CyclicModule>>()->requested_modules()) {
|
||||||
// 1. If moduleRequest.[[Attributes]] contains a Record entry such that entry.[[Key]] is not "type", then:
|
// 1. If moduleRequest.[[Attributes]] contains a Record entry such that entry.[[Key]] is not "type", then:
|
||||||
|
@ -528,6 +530,7 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
|
||||||
// as one that cannot be parsed; in both cases, a syntactic issue makes it impossible to ever
|
// as one that cannot be parsed; in both cases, a syntactic issue makes it impossible to ever
|
||||||
// contemplate linking the module later.
|
// contemplate linking the module later.
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 8. Disallow further import maps given moduleMapRealm.
|
// 8. Disallow further import maps given moduleMapRealm.
|
||||||
HTML::disallow_further_import_maps(*module_map_realm);
|
HTML::disallow_further_import_maps(*module_map_realm);
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
PASS! (Didn't crash)
|
|
@ -0,0 +1,5 @@
|
||||||
|
// NOTE: Doesn't matter what this imports, but this imports itself so there is no import error in test logs.
|
||||||
|
import("./import-in-a-module.js");
|
||||||
|
|
||||||
|
const returnValue = "PASS! (Didn't crash)";
|
||||||
|
export default returnValue;
|
|
@ -0,0 +1,8 @@
|
||||||
|
<script src="../../include.js"></script>
|
||||||
|
<script type="module">
|
||||||
|
import m from "./import-in-a-module.js";
|
||||||
|
|
||||||
|
test(() => {
|
||||||
|
println(m);
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue