Skip to content

Commit edd9d73

Browse files
Robert Burkeandrewrk
Robert Burke
authored andcommitted
Fix buffer overflow in fmt when DAZ is set
1 parent 0a03d68 commit edd9d73

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/std/fmt/errol.zig

+2-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ fn errolSlow(val: f64, buffer: []u8) FloatDecimal {
169169

170170
// digit generation
171171
var buf_index: usize = 0;
172-
while (true) {
172+
const bound = buffer.len - 1;
173+
while (buf_index < bound) {
173174
var hdig = @floatToInt(u8, @floor(high.val));
174175
if ((high.val == @intToFloat(f64, hdig)) and (high.off < 0)) hdig -= 1;
175176

0 commit comments

Comments
 (0)