Skip to content

Commit 38cbdcd

Browse files
committed
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.
1 parent 55c984e commit 38cbdcd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libcore/fmt/num.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ trait GenericRadix {
6565
// characters for a base 2 number.
6666
let zero = T::zero();
6767
let is_nonnegative = x >= zero;
68-
let mut buf = [0; 128];
68+
let mut buf: [u8; 128] = unsafe { mem::uninitialized() };
6969
let mut curr = buf.len();
7070
let base = T::from_u8(self.base());
7171
if is_nonnegative {

0 commit comments

Comments
 (0)