From 20c60053411cf1cc1cc41cc8a94e2bca4e5c466c Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 17 Jul 2025 11:53:20 -0400 Subject: [PATCH] LibWeb: Use TemporaryExecutionContext in structured deserialization No need to manually prepare / clean up a context. We also previously would not have done the clean up steps if structured deserialization threw an exception. --- Libraries/LibWeb/HTML/StructuredSerialize.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Libraries/LibWeb/HTML/StructuredSerialize.cpp b/Libraries/LibWeb/HTML/StructuredSerialize.cpp index bb913516716..a817fe71aee 100644 --- a/Libraries/LibWeb/HTML/StructuredSerialize.cpp +++ b/Libraries/LibWeb/HTML/StructuredSerialize.cpp @@ -64,6 +64,7 @@ #include #include #include +#include #include #include #include @@ -1507,15 +1508,12 @@ WebIDL::ExceptionOr structured_serialize_internal(JS::VM& v // https://html.spec.whatwg.org/multipage/structured-data.html#structureddeserialize WebIDL::ExceptionOr structured_deserialize(JS::VM& vm, SerializationRecord const& serialized, JS::Realm& target_realm, Optional memory) { + TemporaryExecutionContext execution_context { target_realm }; + if (!memory.has_value()) memory = DeserializationMemory { vm.heap() }; - // IMPLEMENTATION DEFINED: We need to make sure there's an execution context for target_realm on the stack before constructing these JS objects - prepare_to_run_script(target_realm); - auto result = TRY(structured_deserialize_internal(vm, serialized.span(), target_realm, *memory)); - - clean_up_after_running_script(target_realm); VERIFY(result.value.has_value()); return *result.value; }