Browse Source

Merge pull request #5 from AzureMarker/fix/realpath-null-case

pull/6/head
Meziu 3 years ago committed by GitHub
parent
commit
aed3d64acc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/lib.rs

10
src/lib.rs

@ -24,9 +24,15 @@ extern "C" fn posix_memalign( @@ -24,9 +24,15 @@ extern "C" fn posix_memalign(
#[no_mangle]
unsafe extern "C" fn realpath(
path: *const libc::c_char,
resolved_path: *mut libc::c_char,
mut resolved_path: *mut libc::c_char,
) -> *mut libc::c_char {
libc::memcpy(resolved_path as _, path as _, libc::strlen(path));
let path_len = libc::strlen(path);
if resolved_path.is_null() {
resolved_path = libc::malloc(path_len + 1) as _;
}
libc::strncpy(resolved_path as _, path as _, path_len + 1);
resolved_path
}

Loading…
Cancel
Save