script: make Error::to_jsval safe (#35411)

Signed-off-by: Stephen Muss <stephenmuss@gmail.com>
This commit is contained in:
Stephen Muss 2025-02-11 10:47:31 +11:00 committed by GitHub
parent 8486e585f5
commit cb588bab6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 41 additions and 64 deletions

View file

@ -417,11 +417,10 @@ impl ReadableStream {
/// <https://streams.spec.whatwg.org/#readable-stream-error>
/// Note: in other use cases this call happens via the controller.
#[allow(unsafe_code)]
pub(crate) fn error_native(&self, error: Error) {
let cx = GlobalScope::get_cx();
rooted!(in(*cx) let mut error_val = UndefinedValue());
unsafe { error.to_jsval(*cx, &self.global(), error_val.handle_mut()) };
error.to_jsval(cx, &self.global(), error_val.handle_mut());
self.error(error_val.handle());
}