authorgravatar for elliot.huang.signed@gmail.combinarycraft007 <elliot.huang.signed@gmail.com> 2025-09-01 17:01:54+08:00
committergravatar for elliot.huang.signed@gmail.combinarycraft007 <elliot.huang.signed@gmail.com> 2025-09-01 17:01:54+08:00
log00b0beb682881da083b548423019483924736c1e
treed0ba12d0dc7e049ab734b6039bae32b3f00f5c81
parentbc7955306e3480fc065277d0b6c5abb6797a27ae

lzma2: fix array list looping logic in appendLz


1 files changed, 7 insertions(+), 1 deletions(-)

lib/std/compress/lzma2.zig+7-1
......@@ -83,11 +83,17 @@ pub const AccumBuffer = struct {
8383 return error.CorruptInput;
8484 }
8585
86 // ensure we have enough capacity for all new bytes.
87 // This prevents the buffer's memory from being reallocated (and freed)
88 // while we are still reading from it.
89 try self.buf.ensureTotalCapacity(allocator, buf_len + len);
90
8691 var offset = buf_len - dist;
8792 var i: usize = 0;
8893 while (i < len) : (i += 1) {
8994 const x = self.buf.items[offset];
90 try self.buf.append(allocator, x);
95 // Since capacity is guaranteed, it's safe to use appendAssumeCapacity.
96 self.buf.appendAssumeCapacity(x);
9197 offset += 1;
9298 }
9399 self.len += len;