| author | |
| committer | |
| log | f07bea20dab813fa1b25c3b3a7abe2fc8c992132 |
| tree | 93bed5c5b3d0fe685048df84b2fd6586183f9329 |
| parent | 97b97ae6202811e207196920018c3b9610957f90 |
| parent | 09d021c908b2c0c320e5b250656a3460ef07736c |
| signature |
Fix memcpy alias bug in std.compress.lzma2 files changed, 11 insertions(+), 1 deletions(-)
lib/std/compress/lzma.zig+1-1| ... | ... | @@ -77,7 +77,7 @@ pub fn Decompress(comptime ReaderType: type) type { |
| 77 | 77 | const input = self.to_read.items; |
| 78 | 78 | const n = @min(input.len, output.len); |
| 79 | 79 | @memcpy(output[0..n], input[0..n]); |
| 80 | @memcpy(input[0 .. input.len - n], input[n..]); | |
| 80 | std.mem.copyForwards(u8, input[0 .. input.len - n], input[n..]); | |
| 81 | 81 | self.to_read.shrinkRetainingCapacity(input.len - n); |
| 82 | 82 | return n; |
| 83 | 83 | } |
lib/std/compress/lzma/test.zig+10| ... | ... | @@ -87,3 +87,13 @@ test "too small uncompressed size in header" { |
| 87 | 87 | @embedFile("testdata/bad-too_small_size-without_eopm-3.lzma"), |
| 88 | 88 | ); |
| 89 | 89 | } |
| 90 | ||
| 91 | test "reading one byte" { | |
| 92 | const compressed = @embedFile("testdata/good-known_size-with_eopm.lzma"); | |
| 93 | var stream = std.io.fixedBufferStream(compressed); | |
| 94 | var decompressor = try lzma.decompress(std.testing.allocator, stream.reader()); | |
| 95 | defer decompressor.deinit(); | |
| 96 | ||
| 97 | var buffer = [1]u8{0}; | |
| 98 | _ = try decompressor.read(buffer[0..]); | |
| 99 | } |