File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -352,14 +352,18 @@ pub(crate) unsafe fn invoke_runtime_callback_with_writer<W: std::io::Write>(
352
352
} ) ;
353
353
}
354
354
355
- // Define the emit_stacktrace_string function that writes directly to the pipe
356
355
unsafe extern "C" fn emit_stacktrace_string_collector ( stacktrace_string : * const c_char ) {
357
- let stacktrace_string_str = std:: ffi:: CStr :: from_ptr ( stacktrace_string) ;
358
- let stacktrace_string_str = stacktrace_string_str. to_str ( ) . unwrap ( ) ;
356
+ if stacktrace_string. is_null ( ) {
357
+ return ;
358
+ }
359
+
360
+ let cstr = std:: ffi:: CStr :: from_ptr ( stacktrace_string) ;
361
+ let bytes = cstr. to_bytes ( ) ;
362
+
359
363
FRAME_WRITER . with ( |writer_cell| {
360
364
if let Some ( writer_ptr) = * writer_cell. borrow ( ) {
361
365
let writer = & mut * writer_ptr;
362
- let _ = writer. write_all ( stacktrace_string_str . as_bytes ( ) ) ;
366
+ let _ = writer. write_all ( bytes ) ;
363
367
let _ = writer. flush ( ) ;
364
368
}
365
369
} ) ;
You can’t perform that action at this time.
0 commit comments