mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 11:37:16 +02:00
LibWeb: Implement IDL overload resolution steps to clamp argument counts
There is a NOTE in our implementation of these steps which states that the effective overload set only contains overloads with the correct number of arguments. While this is true, we should not skip the steps to clamp the inspected argument count to that correct number. Otherwise, we will dereference past the end of the overload set's type list as we blindly iterate over the user-provided arguments. Fixes #18670.
This commit is contained in:
committed by
Andreas Kling
parent
fc3c3aef22
commit
88e060907b
Notes:
sideshowbarker
2024-07-17 02:38:39 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/88e060907b Pull-request: https://github.com/SerenityOS/serenity/pull/18694 Issue: https://github.com/SerenityOS/serenity/issues/18670
@@ -60,8 +60,10 @@ JS::ThrowCompletionOr<ResolvedOverload> resolve_overload(JS::VM& vm, IDL::Effect
|
||||
// 2. Let n be the size of args.
|
||||
// 3. Initialize argcount to be min(maxarg, n).
|
||||
// 4. Remove from S all entries whose type list is not of length argcount.
|
||||
// NOTE: Our caller already performs these steps, so our effective overload set only contains overloads with the correct number of arguments.
|
||||
int argument_count = vm.argument_count();
|
||||
// NOTE: The IDL-generated callers already only provide an overload set containing overloads with the correct number
|
||||
// of arguments. Therefore, we do not need to remove any entry from that set here. However, we do need to handle
|
||||
// when the number of user-provided arguments exceeds the overload set's argument count.
|
||||
int argument_count = min(vm.argument_count(), overloads.is_empty() ? 0 : overloads.items()[0].types.size());
|
||||
|
||||
// 5. If S is empty, then throw a TypeError.
|
||||
if (overloads.is_empty())
|
||||
|
||||
Reference in New Issue
Block a user