LibJS: Convert Console to use MarkedVector<Value>

Using a Vector<Value> is unsafe as GC cannot see the stored values.
This is then vended to outside users of ConsoleClient, e.g. LibWeb and
WebContent, which is then outside of LibJS's control.

An example issue is if the client stores it for later use and forgets
to visit the stored values, meaning they can be destroyed at any time.
We can save the client from this by vending a MarkedVector<Value> to
them.
This commit is contained in:
Luke Wilde 2022-05-07 00:20:22 +01:00 committed by Linus Groh
parent f04911e777
commit 05748ed607
Notes: sideshowbarker 2024-07-18 05:37:06 +09:00
5 changed files with 42 additions and 28 deletions

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Heap/MarkedVector.h>
#include <LibJS/Runtime/Completion.h>
#include <LibWeb/HTML/WorkerDebugConsoleClient.h>
@ -52,7 +53,7 @@ JS::ThrowCompletionOr<JS::Value> WorkerDebugConsoleClient::printer(JS::Console::
return JS::js_undefined();
}
auto output = String::join(" ", arguments.get<Vector<JS::Value>>());
auto output = String::join(" ", arguments.get<JS::MarkedVector<JS::Value>>());
m_console.output_debug_message(log_level, output);
switch (log_level) {