mirror of
https://github.com/servo/servo.git
synced 2025-09-29 16:19:14 +01:00
script: Make set_dictionary_property a safe function (#39191)
Makes `set_dictionary_property` safe. Testing: Changes are internal, this shouldn't affect behavior. Fixes: #39128 Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
This commit is contained in:
parent
af8723c0b1
commit
088d16d634
4 changed files with 13 additions and 20 deletions
|
@ -290,12 +290,9 @@ pub unsafe fn get_dictionary_property(
|
|||
/// Set the property with name `property` from `object`.
|
||||
/// Returns `Err(())` on JSAPI failure, or null object,
|
||||
/// and Ok(()) otherwise
|
||||
///
|
||||
/// # Safety
|
||||
/// `cx` must point to a valid, non-null JSContext.
|
||||
#[allow(clippy::result_unit_err)]
|
||||
pub unsafe fn set_dictionary_property(
|
||||
cx: *mut JSContext,
|
||||
pub fn set_dictionary_property(
|
||||
cx: SafeJSContext,
|
||||
object: HandleObject,
|
||||
property: &str,
|
||||
value: HandleValue,
|
||||
|
@ -305,8 +302,10 @@ pub unsafe fn set_dictionary_property(
|
|||
}
|
||||
|
||||
let property = CString::new(property).unwrap();
|
||||
if !JS_SetProperty(cx, object, property.as_ptr(), value) {
|
||||
return Err(());
|
||||
unsafe {
|
||||
if !JS_SetProperty(*cx, object, property.as_ptr(), value) {
|
||||
return Err(());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue