8000 Replace null bytes in error text with escaped bytes. (#614) · servo/mozjs@3805c67 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3805c67

Browse files
authored
Replace null bytes in error text with escaped bytes. (#614)
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
1 parent 1823562 commit 3805c67

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mozjs/src/error.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ unsafe extern "C" fn get_error_message(
5252
/// passed back to the get_error_message callback.
5353
/// c_uint is u32, so this cast is safe, as is casting to/from i32 from there.
5454
unsafe fn throw_js_error(cx: *mut JSContext, error: &str, error_number: u32) {
55-
let error = CString::new(error).unwrap();
55+
let error = CString::new(error)
56+
.or_else(|_| CString::new(error.replace("\0", "\\u0000")))
57+
.unwrap();
5658
JS_ReportErrorNumberUTF8(
5759
cx,
5860
Some(get_error_message),

0 commit comments

Comments
 (0)
0