Correctly bubble up errors from libbacktrace

This commit is contained in:
Aidan Hobson Sayers
2017-09-12 20:27:54 +01:00
parent a7b7dce02d
commit 15887d786b

View File

@@ -30,6 +30,12 @@ where F: FnMut(&[u8], libc::c_int) -> io::Result<()>
let ret;
let fileline_count = {
let state = unsafe { init_state() };
if state.is_null() {
return Err(io::Error::new(
io::ErrorKind::Other,
"failed to allocate libbacktrace state")
)
}
let mut fileline_win: &mut [FileLine] = &mut fileline_buf;
let fileline_addr = &mut fileline_win as *mut &mut [FileLine];
ret = unsafe {
@@ -62,8 +68,11 @@ pub fn resolve_symname<F>(frame: Frame,
let symname = {
let state = unsafe { init_state() };
if state.is_null() {
None
} else {
return Err(io::Error::new(
io::ErrorKind::Other,
"failed to allocate libbacktrace state")
)
}
let mut data = ptr::null();
let data_addr = &mut data as *mut *const libc::c_char;
let ret = unsafe {
@@ -80,7 +89,6 @@ pub fn resolve_symname<F>(frame: Frame,
CStr::from_ptr(data).to_str().ok()
}
}
}
};
callback(symname)
}