Skip to content

Commit

Permalink
Don't call dladdr for NULL
Browse files Browse the repository at this point in the history
We know this will return nothing and it comes up sometimes during
backtraces, so avoid hitting libc if we can.
  • Loading branch information
alexcrichton committed Aug 7, 2019
1 parent bcfe419 commit 0952f3a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/symbolize/dladdr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ cfg_if::cfg_if! {
inner: mem::zeroed(),
_marker: marker::PhantomData,
};
if libc::dladdr(addr as *mut _, &mut info.inner) != 0 {
// Skip null addresses to avoid calling into libc and having it do
// things with the dynamic symbol table for no reason.
if !addr.is_null() && libc::dladdr(addr as *mut _, &mut info.inner) != 0 {
cb(info)
}
}
Expand Down

0 comments on commit 0952f3a

Please sign in to comment.