Skip to content

Commit

Permalink
Fix remaining, ESPECIALLY unnecessary, uses of uninitialized memory
Browse files Browse the repository at this point in the history
  • Loading branch information
SolraBizna committed Mar 30, 2021
1 parent dd59b30 commit 9a7de8a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/fcgi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ type RecordType = u8;
type RequestId = u16;

fn read_length<T: io::Read>(reader: &mut T) -> Option<io::Result<u32>> {
let mut b1: [u8; 1] = unsafe { std::mem::uninitialized() };
let mut b1 = [0u8; 1];
match reader.read_exact(&mut b1[..]) {
Ok(()) => (),
Err(ref x) if x.kind() == io::ErrorKind::UnexpectedEof
Expand All @@ -127,7 +127,7 @@ fn read_length<T: io::Read>(reader: &mut T) -> Option<io::Result<u32>> {
}
if b1[0] & 0x80 != 0 {
// it is a 31-bit length
let mut b2: [u8; 3] = unsafe { std::mem::uninitialized() };
let mut b2 = [0u8; 3];
match reader.read_exact(&mut b2[..]) {
Ok(()) => (),
Err(x) => return Some(Err(x)),
Expand Down Expand Up @@ -312,15 +312,15 @@ impl<'a, 'z> Instance<'a, 'z> {
current_reqid: NULL_REQUEST_ID,
current_input: 0,
receiver: LowLevelReceiver {
recvbuf: unsafe { std::mem::uninitialized() },
recvbuf: [0u8; RECVBUF_SIZE],
recvbufpos: 0,
recvbufend: 0,
},
options,
keep_conn: true,
input_has_ended: true,
remaining_slice_in_input: &[],
sendbuf: unsafe { std::mem::uninitialized() },
sendbuf: [0u8; SENDBUF_SIZE],
stdout_pos: 0,
}
}
Expand Down

0 comments on commit 9a7de8a

Please sign in to comment.