Skip to content

Commit

Permalink
Rollup merge of rust-lang#49103 - glandium:uninitialized, r=cramertj
Browse files Browse the repository at this point in the history
Use an uninitialized buffer in GenericRadix::fmt_int, like in Display::fmt for numeric types

The code using a slice of that buffer is only ever going to use
bytes that are subsequently initialized.
  • Loading branch information
TimNN authored Mar 26, 2018
2 parents 571734f + 38cbdcd commit fc9dfda
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libcore/fmt/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ trait GenericRadix {
// characters for a base 2 number.
let zero = T::zero();
let is_nonnegative = x >= zero;
let mut buf = [0; 128];
let mut buf: [u8; 128] = unsafe { mem::uninitialized() };
let mut curr = buf.len();
let base = T::from_u8(Self::BASE);
if is_nonnegative {
Expand Down

0 comments on commit fc9dfda

Please sign in to comment.