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};
33use huffman:: { HuffmanTable , HuffmanTableClass } ;
44use marker:: Marker ;
55use marker:: Marker :: * ;
6- use std:: io:: Read ;
6+ use std:: io:: { self , Read } ;
77use std:: ops:: Range ;
88
99#[ derive( Clone , Copy , Debug , PartialEq ) ]
@@ -93,10 +93,14 @@ fn read_length<R: Read>(reader: &mut R, marker: Marker) -> Result<usize> {
9393}
9494
9595fn 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+ }
100104}
101105
102106// Section B.2.2
You can’t perform that action at this time.
0 commit comments