ladybird/Libraries/LibJS
Linus Groh 0603402c80 LibJS: Handle circular references in Array.prototype.join()
This fixes Array.prototype.{join,toString}() crashing with arrays
containing themselves, i.e. circular references.

The spec is suspiciously silent about this, and indeed engine262, a
"100% spec compliant" ECMA-262 implementation, can't handle these cases.
I had a look at some major engines instead and they all seem to keep
track or check for circular references and return an empty string for
already seen objects.

- SpiderMonkey: "AutoCycleDetector detector(cx, obj)"
- V8: "CycleProtectedArrayJoin<JSArray>(...)"
- JavaScriptCore: "StringRecursionChecker checker(globalObject, thisObject)"
- ChakraCore: "scriptContext->CheckObject(thisArg)"

To keep things simple & consistent this uses the same pattern as
JSONObject, MarkupGenerator and js: simply putting each seen object in a
HashTable<Object*>.

Fixes #3929.
2020-11-04 19:35:43 +01:00
..
Heap Everywhere: Add missing <AK/TemporaryChange.h> includes 2020-10-15 23:49:53 +02:00
Runtime LibJS: Handle circular references in Array.prototype.join() 2020-11-04 19:35:43 +01:00
Tests LibJS: Handle circular references in Array.prototype.join() 2020-11-04 19:35:43 +01:00
AST.cpp LibJS: Implement 'new.target' 2020-11-02 22:40:59 +01:00
AST.h LibJS: Implement 'new.target' 2020-11-02 22:40:59 +01:00
CMakeLists.txt LibJS: Split Heap into per-cell-size allocators 2020-10-06 18:50:47 +02:00
Console.cpp LibJS: Move Console from Interpreter to GlobalObject 2020-09-29 21:15:06 +02:00
Console.h LibJS: Move Console from Interpreter to GlobalObject 2020-09-29 21:15:06 +02:00
Forward.h LibJS: Split Heap into per-cell-size allocators 2020-10-06 18:50:47 +02:00
Interpreter.cpp LibJS: Cache commonly used FlyStrings in the VM 2020-10-13 23:57:45 +02:00
Interpreter.h LibJS: Remove some unused Interpreter member functions 2020-10-04 23:10:07 +02:00
Lexer.cpp LibJS: "-->" preceded by token on same line isn't start of HTML-like comment 2020-10-29 22:28:15 +01:00
Lexer.h LibJS: "-->" preceded by token on same line isn't start of HTML-like comment 2020-10-29 22:28:15 +01:00
MarkupGenerator.cpp LibJS: Handle multi-line source code in MarkupGenerator 2020-10-31 20:52:54 +01:00
MarkupGenerator.h Meta: Add a script check the presence of "#pragma once" in header files 2020-05-29 07:59:45 +02:00
Parser.cpp LibJS: Implement 'new.target' 2020-11-02 22:40:59 +01:00
Parser.h LibJS: Implement 'new.target' 2020-11-02 22:40:59 +01:00
Token.cpp LibJS: Use GenericLexer for Token::string_value() 2020-10-29 11:52:31 +01:00
Token.h LibJS: Add message string to Token 2020-10-26 21:38:34 +01:00