Skip to content

Commit

Permalink
Use an uninitialized buffer in GenericRadix::fmt_int, like in Display…
Browse files Browse the repository at this point in the history
…::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
glandium committed Mar 17, 2018
1 parent 55c984e commit 38cbdcd
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 @@ -65,7 +65,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 38cbdcd

Please sign in to comment.