mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
Merge pull request #25105 from binarycraft007/lzma2-fix
lzma2: fix array list looping logic in appendLz
This commit is contained in:
commit
d51d18c986
1 changed files with 11 additions and 10 deletions
|
|
@ -79,17 +79,18 @@ pub const AccumBuffer = struct {
|
||||||
_ = writer;
|
_ = writer;
|
||||||
|
|
||||||
const buf_len = self.buf.items.len;
|
const buf_len = self.buf.items.len;
|
||||||
if (dist > buf_len) {
|
if (dist > buf_len) return error.CorruptInput;
|
||||||
return error.CorruptInput;
|
|
||||||
}
|
|
||||||
|
|
||||||
var offset = buf_len - dist;
|
try self.buf.ensureUnusedCapacity(allocator, len);
|
||||||
var i: usize = 0;
|
const buffer = self.buf.allocatedSlice();
|
||||||
while (i < len) : (i += 1) {
|
const src = buffer[buf_len - dist ..][0..len];
|
||||||
const x = self.buf.items[offset];
|
const dst = buffer[buf_len..][0..len];
|
||||||
try self.buf.append(allocator, x);
|
|
||||||
offset += 1;
|
// This is not a @memmove; it intentionally repeats patterns caused by
|
||||||
}
|
// iterating one byte at a time.
|
||||||
|
for (dst, src) |*d, s| d.* = s;
|
||||||
|
|
||||||
|
self.buf.items.len = buf_len + len;
|
||||||
self.len += len;
|
self.len += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue