mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
jsstring_to_str should accept a NonNull argument for the JS string (#33306)
Instead of asserting the raw pointer is not null, force callers to produce a NonNull pointer. Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com>
This commit is contained in:
parent
642c25d9a7
commit
aadc212b95
6 changed files with 40 additions and 38 deletions
|
@ -237,19 +237,19 @@ pub unsafe fn find_enum_value<'a, T>(
|
|||
v: HandleValue,
|
||||
pairs: &'a [(&'static str, T)],
|
||||
) -> Result<(Option<&'a T>, DOMString), ()> {
|
||||
let jsstr = ToString(cx, v);
|
||||
if jsstr.is_null() {
|
||||
return Err(());
|
||||
match ptr::NonNull::new(ToString(cx, v)) {
|
||||
Some(jsstr) => {
|
||||
let search = jsstring_to_str(cx, jsstr);
|
||||
Ok((
|
||||
pairs
|
||||
.iter()
|
||||
.find(|&&(key, _)| search == *key)
|
||||
.map(|(_, ev)| ev),
|
||||
search,
|
||||
))
|
||||
},
|
||||
None => Err(()),
|
||||
}
|
||||
|
||||
let search = jsstring_to_str(cx, jsstr);
|
||||
Ok((
|
||||
pairs
|
||||
.iter()
|
||||
.find(|&&(key, _)| search == *key)
|
||||
.map(|(_, ev)| ev),
|
||||
search,
|
||||
))
|
||||
}
|
||||
|
||||
/// Returns wether `obj` is a platform object using dynamic unwrap
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue