Skip to content

Commit 42c3d37

Browse files
committed
Remove use of mem::uninitialized in libterm crate
1 parent 05c1e92 commit 42c3d37

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/libterm/win.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
33
// FIXME (#13400): this is only a tiny fraction of the Windows console api
44

5-
extern crate libc;
6-
75
use std::io;
86
use std::io::prelude::*;
97

@@ -122,12 +120,17 @@ impl<T: Write + Send + 'static> WinConsole<T> {
122120

123121
/// Returns `None` whenever the terminal cannot be created for some reason.
124122
pub fn new(out: T) -> io::Result<WinConsole<T>> {
123+
use std::mem::MaybeUninit;
124+
125125
let fg;
126126
let bg;
127127
unsafe {
128-
#[allow(deprecated)]
129-
let mut buffer_info = ::std::mem::uninitialized();
130-
if GetConsoleScreenBufferInfo(GetStdHandle(-11i32 as DWORD), &mut buffer_info) != 0 {
128+
let mut buffer_info = MaybeUninit::<CONSOLE_SCREEN_BUFFER_INFO>::uninit();
129+
if GetConsoleScreenBufferInfo(
130+
GetStdHandle(-11i32 as DWORD),
131+
buffer_info.as_mut_ptr()
132+
) != 0 {
133+
let buffer_info = buffer_info.assume_init() ;
131134
fg = bits_to_color(buffer_info.wAttributes);
132135
bg = bits_to_color(buffer_info.wAttributes >> 4);
133136
} else {

0 commit comments

Comments
 (0)