1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 19:35:06 +00:00

LibJS: Handle getter exception in JSONObject::serialize_json_property()

In the case of an exception in a property getter function we would not
return early, and a subsequent attempt to call the replacer function
would crash the interpreter due to call_internal() asserting.

Fixes #3548.
This commit is contained in:
Linus Groh 2020-09-19 12:57:31 +01:00 committed by Andreas Kling
parent e1965a5a8e
commit c0e4353bde
2 changed files with 12 additions and 0 deletions

View file

@ -150,6 +150,8 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::stringify)
String JSONObject::serialize_json_property(Interpreter& interpreter, StringifyState& state, const PropertyName& key, Object* holder)
{
auto value = holder->get(key);
if (interpreter.exception())
return {};
if (value.is_object()) {
auto to_json = value.as_object().get("toJSON");
if (interpreter.exception())