Remove unsafe annotation add to unsafe blocks (#36399)

Remove the `unsafe` annotation from the `cross_origin_get` function and
add `unsafe` blocks around unsafe code within the function

Testing: Testing is not required as this change does not alter
behaviour.
Fixes: #36358

---------

Signed-off-by: Barigbue <barigbuenbira@gmail.com>
This commit is contained in:
Barigbue Nbira 2025-04-08 19:39:47 +01:00 committed by GitHub
parent 867711c6b9
commit 7fd004adce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -606,7 +606,7 @@ pub(crate) fn maybe_cross_origin_get_prototype<D: DomTypes>(
/// for a maybe-cross-origin object. /// for a maybe-cross-origin object.
/// ///
/// [`CrossOriginGet`]: https://html.spec.whatwg.org/multipage/#crossoriginget-(-o,-p,-receiver-) /// [`CrossOriginGet`]: https://html.spec.whatwg.org/multipage/#crossoriginget-(-o,-p,-receiver-)
pub(crate) unsafe fn cross_origin_get<D: DomTypes>( pub(crate) fn cross_origin_get<D: DomTypes>(
cx: SafeJSContext, cx: SafeJSContext,
proxy: RawHandleObject, proxy: RawHandleObject,
receiver: RawHandleValue, receiver: RawHandleValue,
@ -616,14 +616,16 @@ pub(crate) unsafe fn cross_origin_get<D: DomTypes>(
// > 1. Let `desc` be `? O.[[GetOwnProperty]](P)`. // > 1. Let `desc` be `? O.[[GetOwnProperty]](P)`.
rooted!(in(*cx) let mut descriptor = PropertyDescriptor::default()); rooted!(in(*cx) let mut descriptor = PropertyDescriptor::default());
let mut is_none = false; let mut is_none = false;
if !InvokeGetOwnPropertyDescriptor( if !unsafe {
InvokeGetOwnPropertyDescriptor(
GetProxyHandler(*proxy), GetProxyHandler(*proxy),
*cx, *cx,
proxy, proxy,
id, id,
descriptor.handle_mut().into(), descriptor.handle_mut().into(),
&mut is_none, &mut is_none,
) { )
} {
return false; return false;
} }
@ -654,9 +656,12 @@ pub(crate) unsafe fn cross_origin_get<D: DomTypes>(
} }
rooted!(in(*cx) let mut getter_jsval = UndefinedValue()); rooted!(in(*cx) let mut getter_jsval = UndefinedValue());
unsafe {
getter.get().to_jsval(*cx, getter_jsval.handle_mut()); getter.get().to_jsval(*cx, getter_jsval.handle_mut());
}
// > 7. Return `? Call(getter, Receiver)`. // > 7. Return `? Call(getter, Receiver)`.
unsafe {
jsapi::Call( jsapi::Call(
*cx, *cx,
receiver, receiver,
@ -665,6 +670,7 @@ pub(crate) unsafe fn cross_origin_get<D: DomTypes>(
vp, vp,
) )
} }
}
/// Implementation of [`CrossOriginSet`]. /// Implementation of [`CrossOriginSet`].
/// ///