mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
Merge pull request #21447 from Szwagi/fix-lzma-memcpy-alias
Fix memcpy alias bug in std.compress.lzma
This commit is contained in:
commit
f07bea20da
2 changed files with 11 additions and 1 deletions
|
|
@ -77,7 +77,7 @@ pub fn Decompress(comptime ReaderType: type) type {
|
|||
const input = self.to_read.items;
|
||||
const n = @min(input.len, output.len);
|
||||
@memcpy(output[0..n], input[0..n]);
|
||||
@memcpy(input[0 .. input.len - n], input[n..]);
|
||||
std.mem.copyForwards(u8, input[0 .. input.len - n], input[n..]);
|
||||
self.to_read.shrinkRetainingCapacity(input.len - n);
|
||||
return n;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,3 +87,13 @@ test "too small uncompressed size in header" {
|
|||
@embedFile("testdata/bad-too_small_size-without_eopm-3.lzma"),
|
||||
);
|
||||
}
|
||||
|
||||
test "reading one byte" {
|
||||
const compressed = @embedFile("testdata/good-known_size-with_eopm.lzma");
|
||||
var stream = std.io.fixedBufferStream(compressed);
|
||||
var decompressor = try lzma.decompress(std.testing.allocator, stream.reader());
|
||||
defer decompressor.deinit();
|
||||
|
||||
var buffer = [1]u8{0};
|
||||
_ = try decompressor.read(buffer[0..]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue