From 790a334887269c3b6da589e5805f84733ed1d334 Mon Sep 17 00:00:00 2001 From: 131250106 <7438696+131250106@users.noreply.github.com> Date: Thu, 12 Jul 2018 11:14:30 +0800 Subject: [PATCH] Fix sigfault on lldb::SBFrame::function_name (lldb) bt * thread #1, name = 'crash_analyse', stop reason = signal SIGSEGV: invalid address (fault address: 0x0) * frame #0: 0x00007ffff60ec661 libc.so.6`__strlen_avx2 + 17 frame #1: 0x000055555556b859 crash_analyse`std::ffi::c_str::CStr::from_ptr::h7d6778659191997d at c_str.rs:904 frame #2: 0x000055555555ed45 crash_analyse`lldb::frame::SBFrame::function_name::h6e8217ef78893c79(self=0x00007fffffffe848) at frame.rs:153 --- src/frame.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frame.rs b/src/frame.rs index 4f1b9fb6..11752586 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -150,7 +150,7 @@ impl SBFrame { /// See also `is_inlined`. pub fn function_name(&self) -> Option<&str> { unsafe { - match CStr::from_ptr(sys::SBFrameGetFunctionName(self.raw)).to_str() { + match CStr::from_ptr(sys::SBFrameGetFunctionName(self.raw).as_ref()?).to_str() { Ok(s) => Some(s), _ => None, }