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

@ -219,14 +219,11 @@ impl Promise {
self.reject(cx, v.handle());
}
#[allow(unsafe_code)]
pub(crate) fn reject_error(&self, error: Error) {
let cx = GlobalScope::get_cx();
let _ac = enter_realm(self);
rooted!(in(*cx) let mut v = UndefinedValue());
unsafe {
error.to_jsval(*cx, &self.global(), v.handle_mut());
}
error.to_jsval(cx, &self.global(), v.handle_mut());
self.reject(cx, v.handle());
}