File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ use error::{Error, Result};
3
3
use huffman:: { HuffmanTable , HuffmanTableClass } ;
4
4
use marker:: Marker ;
5
5
use marker:: Marker :: * ;
6
- use std:: io:: Read ;
6
+ use std:: io:: { self , Read } ;
7
7
use std:: ops:: Range ;
8
8
9
9
#[ derive( Clone , Copy , Debug , PartialEq ) ]
@@ -93,10 +93,14 @@ fn read_length<R: Read>(reader: &mut R, marker: Marker) -> Result<usize> {
93
93
}
94
94
95
95
fn skip_bytes < R : Read > ( reader : & mut R , length : usize ) -> Result < ( ) > {
96
- let mut buffer = vec ! [ 0u8 ; length] ;
97
- reader. read_exact ( & mut buffer) ?;
98
-
99
- Ok ( ( ) )
96
+ let length = length as u64 ;
97
+ let to_skip = & mut reader. by_ref ( ) . take ( length) ;
98
+ let copied = io:: copy ( to_skip, & mut io:: sink ( ) ) ?;
99
+ if copied < length {
100
+ Err ( Error :: Io ( io:: ErrorKind :: UnexpectedEof . into ( ) ) )
101
+ } else {
102
+ Ok ( ( ) )
103
+ }
100
104
}
101
105
102
106
// Section B.2.2
You can’t perform that action at this time.
0 commit comments