Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make conversions to vector safe #235

Merged
merged 1 commit into from Jan 18, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -502,14 +502,13 @@ impl<C: Clone, T: FromJSValConvertible<Config=C>> FromJSValConvertible for Vec<T
return Err(())
}

// HandleValue -> HandleObject
let handle_obj = Handle::from_marked_location(&value.to_object());
if JS_GetArrayLength(cx, handle_obj, &mut length) {
let obj = RootedObject::new(cx, value.to_object());
if JS_GetArrayLength(cx, obj.handle(), &mut length) {
let mut ret = Vec::with_capacity(length as usize);

for i in 0..length {
let mut val = RootedValue::new(cx, UndefinedValue());
assert!(JS_GetElement(cx, handle_obj, i, val.handle_mut()));
assert!(JS_GetElement(cx, obj.handle(), i, val.handle_mut()));
ret.push(try!(T::from_jsval(cx, val.handle(), option.clone())));
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.