Handle failed string conversions in console.log. (#33085)

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2024-08-16 12:49:56 -04:00 committed by GitHub
parent 4df7a1af25
commit 3829e91662
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View file

@ -221,6 +221,7 @@ impl FromJSValConvertible for DOMString {
/// Convert the given `JSString` to a `DOMString`. Fails if the string does not
/// contain valid UTF-16.
pub unsafe fn jsstring_to_str(cx: *mut JSContext, s: *mut JSString) -> DOMString {
assert!(!s.is_null());
let latin1 = JS_DeprecatedStringHasLatin1Chars(s);
DOMString::from_string(if latin1 {
latin1_to_string(cx, s)