File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -184,6 +184,23 @@ impl Operation for Decoder<'_> {
184
184
. map_err ( map_error_code)
185
185
}
186
186
187
+ fn flush < C : WriteBuf + ?Sized > (
188
+ & mut self ,
189
+ output : & mut OutBuffer < ' _ , C > ,
190
+ ) -> io:: Result < usize > {
191
+ // To flush, we just offer no additional input.
192
+ self . run ( & mut InBuffer :: around ( & [ ] ) , output) ?;
193
+
194
+ // We don't _know_ how much (decompressed data) there is still in buffer.
195
+ if output. pos ( ) < output. dst . capacity ( ) {
196
+ // We only know when there's none (the output buffer is not full).
197
+ Ok ( 0 )
198
+ } else {
199
+ // Otherwise, pretend there's still "1 byte" remaining.
200
+ Ok ( 1 )
201
+ }
202
+ }
203
+
187
204
fn reinit ( & mut self ) -> io:: Result < ( ) > {
188
205
self . context
189
206
. reset ( zstd_safe:: ResetDirective :: SessionOnly )
Original file line number Diff line number Diff line change
1
+ const TEXT : & [ u8 ] = include_bytes ! ( "../assets/example.txt" ) ;
2
+
3
+ #[ test]
4
+ #[ should_panic]
5
+ fn test_issue_182 ( ) {
6
+ use std:: io:: BufRead ;
7
+
8
+ let compressed = zstd:: encode_all ( TEXT , 3 ) . unwrap ( ) ;
9
+ let truncated = & compressed[ ..compressed. len ( ) / 2 ] ;
10
+
11
+ let rdr = zstd:: Decoder :: new ( truncated) . unwrap ( ) ;
12
+ let rdr = std:: io:: BufReader :: new ( rdr) ;
13
+ for line in rdr. lines ( ) {
14
+ line. unwrap ( ) ;
15
+ }
16
+ }
You can’t perform that action at this time.
0 commit comments