js: Don't pass error strings as the format argument to outln()

This fixes a crash when the error contains '{}', or an invalid format
string.
This commit is contained in:
Ali Mohammad Pur 2022-07-16 10:15:51 +04:30 committed by Linus Groh
commit 4387ad9fc6
Notes: sideshowbarker 2024-07-17 08:44:32 +09:00

View file

@ -1187,7 +1187,7 @@ static bool parse_and_run(JS::Interpreter& interpreter, StringView source, Strin
auto hint = error.source_location_hint(source);
if (!hint.is_empty())
outln("{}", hint);
outln(error.to_string());
outln("{}", error.to_string());
result = interpreter.vm().throw_completion<JS::SyntaxError>(interpreter.global_object(), error.to_string());
} else {
auto return_early = run_script_or_module(script_or_error.value());