Skip to content

Commit 7095d6b

Browse files
committed
Catch Frame being missing at image end
The decoding expected a frame to exist by unwrapping its option but an image that ends directly (in 4 bytes) will trip this condition.
1 parent ed1b479 commit 7095d6b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/decoder.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ impl<R: Read> Decoder<R> {
409409
previous_marker = marker;
410410
}
411411

412+
if self.frame.is_none() {
413+
return Err(Error::Format("end of image encountered before frame".to_owned()));
414+
}
415+
412416
let frame = self.frame.as_ref().unwrap();
413417

414418
// If we're decoding a progressive jpeg and a component is unfinished, render what we've got

0 commit comments

Comments
 (0)