Fix buffer overflow in fmt when DAZ is set

This commit is contained in:
Robert Burke 2023-01-11 20:37:25 +00:00 committed by Andrew Kelley
parent 0a03d68594
commit edd9d73b0d

View file

@ -169,7 +169,8 @@ fn errolSlow(val: f64, buffer: []u8) FloatDecimal {
// digit generation // digit generation
var buf_index: usize = 0; var buf_index: usize = 0;
while (true) { const bound = buffer.len - 1;
while (buf_index < bound) {
var hdig = @floatToInt(u8, @floor(high.val)); var hdig = @floatToInt(u8, @floor(high.val));
if ((high.val == @intToFloat(f64, hdig)) and (high.off < 0)) hdig -= 1; if ((high.val == @intToFloat(f64, hdig)) and (high.off < 0)) hdig -= 1;