zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit edd9d73b0da03f9220493be6ad3d590f3bab0d5f (tree)
parent 0a03d68594374698b5d751530d6ee7f47a2f75b3
Author: Robert Burke <robert.burke@ltcm.lol>
Date:   Wed, 11 Jan 2023 20:37:25 +0000

Fix buffer overflow in fmt when DAZ is set

Diffstat:
Mlib/std/fmt/errol.zig | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

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