aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/xmlhttprequest.rs
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-07-13 12:00:30 +0200
committerMs2ger <ms2ger@gmail.com>2014-07-13 12:00:30 +0200
commit818eb864b33ae08fb57bc3c196fba96f02c3786a (patch)
treeaa713f41dc9cff3fc5eb95dc76c2416b2ac43f6b /src/components/script/dom/xmlhttprequest.rs
parente6f2342036070073eb604b1a667fa0030e3bb99b (diff)
downloadservo-818eb864b33ae08fb57bc3c196fba96f02c3786a.tar.gz
servo-818eb864b33ae08fb57bc3c196fba96f02c3786a.zip
Handle exceptions from JS_ParseJSON in XMLHttpRequest.response.
Diffstat (limited to 'src/components/script/dom/xmlhttprequest.rs')
-rw-r--r--src/components/script/dom/xmlhttprequest.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/components/script/dom/xmlhttprequest.rs b/src/components/script/dom/xmlhttprequest.rs
index c20feae0437..40a1a9778b1 100644
--- a/src/components/script/dom/xmlhttprequest.rs
+++ b/src/components/script/dom/xmlhttprequest.rs
@@ -36,6 +36,7 @@ use http::method::{Method, Get, Head, Connect, Trace, ExtensionMethod};
use http::status::Status;
use js::jsapi::{JS_AddObjectRoot, JS_ParseJSON, JS_RemoveObjectRoot, JSContext};
+use js::jsapi::JS_ClearPendingException;
use js::jsval::{JSVal, NullValue, UndefinedValue};
use libc;
@@ -617,7 +618,10 @@ impl<'a> XMLHttpRequestMethods<'a> for JSRef<'a, XMLHttpRequest> {
let decoded = UTF_8.decode(self.response.deref().borrow().as_slice(), DecodeReplace).unwrap().to_string().to_utf16();
let mut vp = UndefinedValue();
unsafe {
- JS_ParseJSON(cx, decoded.as_ptr(), decoded.len() as u32, &mut vp);
+ if JS_ParseJSON(cx, decoded.as_ptr(), decoded.len() as u32, &mut vp) == 0 {
+ JS_ClearPendingException(cx);
+ return NullValue();
+ }
}
vp
}