Skip to content

Commit

Permalink
Fix panic on invalid string in callback
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigodd authored and grovesNL committed Jan 3, 2024
1 parent c4a5f71 commit e33eebf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3214,8 +3214,8 @@ extern "system" fn raw_debug_message_callback(
let _result = std::panic::catch_unwind(move || unsafe {
let callback: &mut DebugCallback = &mut *(user_param as *mut DebugCallback);
let slice = std::slice::from_raw_parts(message as *const u8, length as usize);
let msg = std::str::from_utf8(slice).unwrap();
(callback)(source, gltype, id, severity, msg);
let msg = String::from_utf8_lossy(slice);
(callback)(source, gltype, id, severity, &msg);
});
}

Expand Down

0 comments on commit e33eebf

Please sign in to comment.