Throw on bad ByteStrings

This commit is contained in:
Michael Wu 2015-10-12 10:47:49 -04:00
parent e733a7c46a
commit 3129fb2330
3 changed files with 14 additions and 1 deletions

View file

@ -577,7 +577,7 @@ impl FromJSValConvertible for ByteString {
let char_vec = slice::from_raw_parts(chars, length as usize);
if char_vec.iter().any(|&c| c > 0xFF) {
// XXX Throw
throw_type_error(cx, "Invalid ByteString");
Err(())
} else {
Ok(ByteString::new(char_vec.iter().map(|&c| c as u8).collect()))