Browse Source

Avoid capturing a pointer into a temporary CString buffer.

pull/534/head
Dan Gohman 5 years ago
parent
commit
dd27237c74
  1. 7
      crates/wasi-c/src/instantiate.rs

7
crates/wasi-c/src/instantiate.rs

@ -146,11 +146,8 @@ pub fn instantiate_wasi_c(
let mut wasm_fd = 3;
for (dir, file) in preopened_dirs {
assert!(fd_table_insert_existing(curfds, wasm_fd, file.as_raw_fd()));
assert!(fd_prestats_insert(
prestats,
CString::new(dir.as_str()).unwrap().as_ptr(),
wasm_fd,
));
let dir_cstr = CString::new(dir.as_str()).unwrap();
assert!(fd_prestats_insert(prestats, dir_cstr.as_ptr(), wasm_fd));
wasm_fd += 1;
}
}

Loading…
Cancel
Save