mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-24 04:58:22 +00:00
Handle nullptr char* in Rust
This commit is contained in:
parent
67845f9c21
commit
3517e6d752
@ -108,7 +108,11 @@ macro_rules! cstr {
|
||||
}
|
||||
|
||||
pub fn ptr_to_str<'a, T>(ptr: *const T) -> &'a str {
|
||||
unsafe { CStr::from_ptr(ptr.cast()) }.to_str().unwrap_or("")
|
||||
if ptr.is_null() {
|
||||
"(null)"
|
||||
} else {
|
||||
unsafe { CStr::from_ptr(ptr.cast()) }.to_str().unwrap_or("")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn errno() -> &'static mut i32 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user