Skip to content

Commit 6a45e08

Browse files
makenowjustbcardiff
authored andcommittedMar 27, 2017
Flate: try to inflate even if @stream.avail_in is 0 (#4193)
Fix #4192 Probably LibZ::Error::STREAM_END is only way to detect the end of a stream.
1 parent 3c74890 commit 6a45e08

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed
 

Diff for: ‎spec/std/flate/flate_spec.cr

+20
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@ require "spec"
22
require "flate"
33

44
module Flate
5+
describe Reader do
6+
it "should read byte by byte (#4192)" do
7+
io = IO::Memory.new
8+
"cbc9cc4b350402ae1c20c30808b800".scan(/../).each do |match|
9+
io.write_byte match[0].to_u8(16)
10+
end
11+
io.rewind
12+
13+
reader = Reader.new(io)
14+
15+
str = String::Builder.build do |builder|
16+
while b = reader.read_byte
17+
builder.write_byte b
18+
end
19+
end
20+
21+
str.should eq("line1111\nline2222\n")
22+
end
23+
end
24+
525
describe Writer do
626
it "should be able to write" do
727
message = "this is a test string !!!!\n"

Diff for: ‎src/flate/reader.cr

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class Flate::Reader
7777
@stream.next_in = @buf.to_unsafe
7878
@stream.avail_in = @io.read(@buf.to_slice).to_u32
7979
end
80-
return 0 if @stream.avail_in == 0
8180
end
8281

8382
old_avail_in = @stream.avail_in

0 commit comments

Comments
 (0)