Skip to content

Commit

Permalink
LibWeb: Ensure EC on stack when resolving/rejecting image decode promise
Browse files Browse the repository at this point in the history
Fixes #419
awesomekling committed Jul 6, 2024
1 parent 0a1fc7e commit 9c80326
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
Original file line number Diff line number Diff line change
@@ -293,6 +293,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> HTMLImageElement::decode() co
return false;

auto exception = WebIDL::EncodingError::create(realm, "Node document not fully active"_fly_string);
HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*this));
WebIDL::reject_promise(realm, promise, exception);
return true;
};
@@ -302,6 +303,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> HTMLImageElement::decode() co
return false;

auto exception = WebIDL::EncodingError::create(realm, "Current request state is broken"_fly_string);
HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*this));
WebIDL::reject_promise(realm, promise, exception);
return true;
};
@@ -349,7 +351,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> HTMLImageElement::decode() co
// (Typically, this would only be violated in low-memory situations that require evicting decoded image data, or when the image is too large
// to keep in decoded form for this period of time.)

HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm) };
HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*this));
WebIDL::resolve_promise(realm, promise, JS::js_undefined());
}
});

0 comments on commit 9c80326

Please sign in to comment.