Skip to content
Snippets Groups Projects
Commit f661d5d1 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Fix use of uninitialized memory

parent 9d24e615
No related branches found
No related tags found
No related merge requests found
use core::mem; use core::{mem, ptr};
use core::sync::atomic::AtomicBool; use core::sync::atomic::AtomicBool;
use header::errno; use header::errno;
...@@ -67,14 +67,16 @@ pub unsafe fn _fdopen(fd: c_int, mode: *const c_char) -> Option<*mut FILE> { ...@@ -67,14 +67,16 @@ pub unsafe fn _fdopen(fd: c_int, mode: *const c_char) -> Option<*mut FILE> {
if f.is_null() { if f.is_null() {
None None
} else { } else {
(*f).flags = flags; ptr::write(f, FILE {
(*f).read = None; flags: flags,
(*f).write = None; read: None,
(*f).fd = fd; write: None,
(*f).buf = vec![0u8; BUFSIZ + UNGET]; fd: fd,
(*f).buf_char = -1; buf: vec![0u8; BUFSIZ + UNGET],
(*f).unget = UNGET; buf_char: -1,
(*f).lock = AtomicBool::new(false); unget: UNGET,
lock: AtomicBool::new(false)
});
Some(f) Some(f)
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment