diff options
| author | Tim Neumann <mail@timnn.me> | 2018-03-26 15:14:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-03-26 15:14:56 +0200 |
| commit | fc9dfda6adcbbd7f13bba1781ae35371dd48fa81 (patch) | |
| tree | 591f9d602a7a8d0918ab6ad3af6b5c92afe31f40 | |
| parent | 571734fdd77460881d5db31be8970bcecc380f18 (diff) | |
| parent | 38cbdcd0b1791e68c9485d8db6e81cf2d6765572 (diff) | |
| download | rust-fc9dfda6adcbbd7f13bba1781ae35371dd48fa81.tar.gz rust-fc9dfda6adcbbd7f13bba1781ae35371dd48fa81.zip | |
Rollup merge of #49103 - glandium:uninitialized, r=cramertj
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.
| -rw-r--r-- | src/libcore/fmt/num.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 427765aed20..4451ab445cc 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -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 { |
