Skip to content

Commit 6904984

Browse files
Robert Burkematu3ba
authored andcommitted
Fix buffer overflow in fmt when DAZ is set
1 parent bc9fe16 commit 6904984

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/std/fmt/errol.zig

Lines changed: 2 additions & 1 deletion
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)