egl: Fix segfault in egl logging for empty command strings
This commit is contained in:
parent
7e4e78151a
commit
3e4d93dfff
|
@ -27,8 +27,12 @@ extern "system" fn egl_debug_log(
|
||||||
let _ = std::panic::catch_unwind(move || unsafe {
|
let _ = std::panic::catch_unwind(move || unsafe {
|
||||||
let msg = std::ffi::CStr::from_ptr(message as *const _);
|
let msg = std::ffi::CStr::from_ptr(message as *const _);
|
||||||
let message_utf8 = msg.to_string_lossy();
|
let message_utf8 = msg.to_string_lossy();
|
||||||
|
let command_utf8 = if !command.is_null() {
|
||||||
let cmd = std::ffi::CStr::from_ptr(command as *const _);
|
let cmd = std::ffi::CStr::from_ptr(command as *const _);
|
||||||
let command_utf8 = cmd.to_string_lossy();
|
cmd.to_string_lossy()
|
||||||
|
} else {
|
||||||
|
std::borrow::Cow::Borrowed("")
|
||||||
|
};
|
||||||
let logger = crate::slog_or_fallback(None).new(slog::o!("backend" => "egl"));
|
let logger = crate::slog_or_fallback(None).new(slog::o!("backend" => "egl"));
|
||||||
match severity {
|
match severity {
|
||||||
egl::DEBUG_MSG_CRITICAL_KHR | egl::DEBUG_MSG_ERROR_KHR => {
|
egl::DEBUG_MSG_CRITICAL_KHR | egl::DEBUG_MSG_ERROR_KHR => {
|
||||||
|
|
Loading…
Reference in New Issue