diff --git a/Libraries/LibJS/Bytecode/Interpreter.cpp b/Libraries/LibJS/Bytecode/Interpreter.cpp index 96cc3387cdb..a462c6543f0 100644 --- a/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -1732,6 +1732,8 @@ inline ThrowCompletionOr get_object_property_iterator(VM& vm, Value val continue; auto descriptor = TRY(object_to_check->internal_get_own_property(property_key)); + if (!descriptor.has_value()) + continue; if (!*descriptor->enumerable) non_enumerable_properties.set(move(property_key)); else diff --git a/Libraries/LibJS/Tests/builtins/Proxy/iterate-over-proxy.js b/Libraries/LibJS/Tests/builtins/Proxy/iterate-over-proxy.js new file mode 100644 index 00000000000..e6baadbe9aa --- /dev/null +++ b/Libraries/LibJS/Tests/builtins/Proxy/iterate-over-proxy.js @@ -0,0 +1,12 @@ +test("iterate over bogus proxy", () => { + expect(() => { + let proxy = new Proxy([123], { + getOwnPropertyDescriptor: function (p) { + return undefined; + }, + }); + + for (const p in proxy) { + } + }).toThrow(); +});