Rollup merge of #141239 - RalfJung:dladdr-fname, r=Noratrieb
dladdr cannot leave dli_fname to be null There are two places in the repo calling `dladdr`, and they are inconsistent wrt their assumption of whether the `dli_fname` field can be null. Let's make them consistent. I see nothing in the docs that allows it to be null, but just to be on the safe side let's make this an assertion so hopefully we get a report if that ever happens.
This commit is contained in:
@@ -82,9 +82,7 @@ fn current_dll_path() -> Result<PathBuf, String> {
|
||||
let fname_ptr = info.dli_fname.as_ptr();
|
||||
#[cfg(not(target_os = "cygwin"))]
|
||||
let fname_ptr = {
|
||||
if info.dli_fname.is_null() {
|
||||
return Err("dladdr returned null pointer".into());
|
||||
}
|
||||
assert!(!info.dli_fname.is_null(), "the docs do not allow dladdr to be null");
|
||||
info.dli_fname
|
||||
};
|
||||
let bytes = CStr::from_ptr(fname_ptr).to_bytes();
|
||||
|
||||
Reference in New Issue
Block a user