mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Ensure ConsumeBodyPromiseHandler values are always rooted (#34194)
* script: Root the use of ComsumeBodyPromiseHandler. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Update mozjs and run crown on mozjs_sys. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
5f927a2c28
commit
20d67bdc44
3 changed files with 10 additions and 8 deletions
|
@ -611,6 +611,8 @@ impl Callback for ConsumeBodyPromiseRejectionHandler {
|
|||
}
|
||||
}
|
||||
|
||||
impl js::gc::Rootable for ConsumeBodyPromiseHandler {}
|
||||
|
||||
#[derive(Clone, JSTraceable, MallocSizeOf)]
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
/// The promise handler used to consume the body,
|
||||
|
@ -747,7 +749,6 @@ pub fn consume_body<T: BodyMixin + DomObject>(
|
|||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-body-consume-body
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
fn consume_body_with_promise<T: BodyMixin + DomObject>(
|
||||
object: &T,
|
||||
body_type: BodyType,
|
||||
|
@ -777,14 +778,15 @@ fn consume_body_with_promise<T: BodyMixin + DomObject>(
|
|||
// https://fetch.spec.whatwg.org/#concept-read-all-bytes-from-readablestream
|
||||
let read_promise = stream.read_a_chunk(can_gc);
|
||||
|
||||
let promise_handler = Box::new(ConsumeBodyPromiseHandler {
|
||||
let cx = GlobalScope::get_cx();
|
||||
rooted!(in(*cx) let mut promise_handler = Some(ConsumeBodyPromiseHandler {
|
||||
result_promise: promise.clone(),
|
||||
stream: Some(Dom::from_ref(&stream)),
|
||||
body_type: DomRefCell::new(Some(body_type)),
|
||||
mime_type: DomRefCell::new(Some(object.get_mime_type(can_gc))),
|
||||
// Step 2.
|
||||
bytes: DomRefCell::new(Some(vec![])),
|
||||
});
|
||||
}));
|
||||
|
||||
let rejection_handler = Box::new(ConsumeBodyPromiseRejectionHandler {
|
||||
result_promise: promise,
|
||||
|
@ -792,7 +794,7 @@ fn consume_body_with_promise<T: BodyMixin + DomObject>(
|
|||
|
||||
let handler = PromiseNativeHandler::new(
|
||||
&object.global(),
|
||||
Some(promise_handler),
|
||||
promise_handler.take().map(|h| Box::new(h) as Box<_>),
|
||||
Some(rejection_handler),
|
||||
);
|
||||
// We are already in a realm and a script.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue