dladdr cannot leave dli_fname to be null

This commit is contained in:
Ralf Jung
2025-05-19 08:20:03 +02:00
parent e42bbfe1f7
commit d22f53b970
2 changed files with 5 additions and 7 deletions

View File

@@ -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();