mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 06:05:39 +08:00
Fix latent crash in test_wwrite_to_fd
For whatever reason this did not crash until we made it a proper Rust unit test.
This commit is contained in:
parent
3e3441429a
commit
1b7d4f3b90
|
@ -1,7 +1,7 @@
|
|||
use crate::ffi_tests::add_test;
|
||||
use libc::{c_void, O_CREAT, O_RDWR, O_TRUNC, SEEK_SET};
|
||||
use rand::random;
|
||||
use std::ffi::CString;
|
||||
use std::{ffi::CString, ptr};
|
||||
|
||||
use crate::fallback::fish_mkstemp_cloexec;
|
||||
|
||||
|
@ -86,7 +86,11 @@ add_test!("test_wwrite_to_fd", || {
|
|||
let read_amt = unsafe {
|
||||
libc::read(
|
||||
fd.fd(),
|
||||
(&mut contents[0]) as *mut u8 as *mut c_void,
|
||||
if size == 0 {
|
||||
ptr::null_mut()
|
||||
} else {
|
||||
(&mut contents[0]) as *mut u8 as *mut c_void
|
||||
},
|
||||
narrow.len(),
|
||||
)
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user