egl: Fix segfault in egl logging for empty command strings

This commit is contained in:
Victor Brekenfeld 2021-07-25 01:49:43 +02:00 committed by Victor Berger
parent 7e4e78151a
commit 3e4d93dfff
1 changed files with 6 additions and 2 deletions

View File

@ -27,8 +27,12 @@ extern "system" fn egl_debug_log(
let _ = std::panic::catch_unwind(move || unsafe {
let msg = std::ffi::CStr::from_ptr(message as *const _);
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 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"));
match severity {
egl::DEBUG_MSG_CRITICAL_KHR | egl::DEBUG_MSG_ERROR_KHR => {