aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/console.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2024-08-16 12:49:56 -0400
committerGitHub <noreply@github.com>2024-08-16 16:49:56 +0000
commit3829e91662c2f139d9514aa1b5ede4462000f43a (patch)
tree14d9c43faa2e250bc3566c87709903f0a1f63ce7 /components/script/dom/console.rs
parent4df7a1af25b46146fc5a580ad2e50f2ebe91e154 (diff)
downloadservo-3829e91662c2f139d9514aa1b5ede4462000f43a.tar.gz
servo-3829e91662c2f139d9514aa1b5ede4462000f43a.zip
Handle failed string conversions in console.log. (#33085)
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Diffstat (limited to 'components/script/dom/console.rs')
-rw-r--r--components/script/dom/console.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/components/script/dom/console.rs b/components/script/dom/console.rs
index f1e21b5897b..ae041dfa7da 100644
--- a/components/script/dom/console.rs
+++ b/components/script/dom/console.rs
@@ -73,6 +73,9 @@ where
unsafe fn handle_value_to_string(cx: *mut jsapi::JSContext, value: HandleValue) -> DOMString {
rooted!(in(cx) let mut js_string = std::ptr::null_mut::<jsapi::JSString>());
js_string.set(JS_ValueToSource(cx, value));
+ if js_string.is_null() {
+ return "<error converting value to string>".into();
+ }
jsstring_to_str(cx, *js_string)
}