Skip to content

Commit

Permalink
Auto merge of servo#238 - stspyder:master, r=Ms2ger
Browse files Browse the repository at this point in the history
Throw type error on converting non objects to sequence

Fix for servo#237

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/rust-mozjs/238)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Feb 8, 2016
2 parents b96675b + f2f0770 commit 62d23de
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ impl<C: Clone, T: FromJSValConvertible<Config=C>> FromJSValConvertible for Vec<T
let mut length = 0;

if !value.is_object() {
throw_type_error(cx, "Non objects cannot be converted to sequence");
return Err(())
}

Expand All @@ -508,7 +509,10 @@ impl<C: Clone, T: FromJSValConvertible<Config=C>> FromJSValConvertible for Vec<T

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

Expand Down

0 comments on commit 62d23de

Please sign in to comment.