| ... | ... | @@ -347,6 +347,7 @@ pub fn Inflate(comptime container: Container, comptime LookaheadType: type, comp |
| 347 | 347 | /// If the number of bytes read is 0, it means end of stream. |
| 348 | 348 | /// End of stream is not an error condition. |
| 349 | 349 | pub fn read(self: *Self, buffer: []u8) Error!usize { |
| 350 | if (buffer.len == 0) return 0; |
| 350 | 351 | const out = try self.get(buffer.len); |
| 351 | 352 | @memcpy(buffer[0..out.len], out); |
| 352 | 353 | return out.len; |
| ... | ... | @@ -556,3 +557,14 @@ test "bug 18966" { |
| 556 | 557 | try decompress(.gzip, in.reader(), out.writer()); |
| 557 | 558 | try testing.expectEqualStrings(expect, out.items); |
| 558 | 559 | } |
| 560 | |
| 561 | test "bug 19895" { |
| 562 | const input = &[_]u8{ |
| 563 | 0b0000_0001, 0b0000_1100, 0x00, 0b1111_0011, 0xff, // deflate fixed buffer header len, nlen |
| 564 | 'H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', 0x0a, // non compressed data |
| 565 | }; |
| 566 | var in = std.io.fixedBufferStream(input); |
| 567 | var decomp = decompressor(.raw, in.reader()); |
| 568 | var buf: [0]u8 = undefined; |
| 569 | try testing.expectEqual(0, try decomp.read(&buf)); |
| 570 | } |