diff --git a/src/decoder.rs b/src/decoder.rs index 9f59aff7..dca49820 100644 --- a/src/decoder.rs +++ b/src/decoder.rs @@ -409,6 +409,10 @@ impl Decoder { previous_marker = marker; } + if self.frame.is_none() { + return Err(Error::Format("end of image encountered before frame".to_owned())); + } + let frame = self.frame.as_ref().unwrap(); // If we're decoding a progressive jpeg and a component is unfinished, render what we've got diff --git a/tests/crashtest/images/README.md b/tests/crashtest/images/README.md index 3e8a4eca..f3853db2 100644 --- a/tests/crashtest/images/README.md +++ b/tests/crashtest/images/README.md @@ -7,3 +7,4 @@ derive-huffman-codes-overflow.jpg | Found by Pascal Hertleif (@killercup) while missing-sof.jpg | Found by Corey Farwell (@frewsxcv) when fuzz testing extraneous-bytes-after-sos.jpg | Scan from brother DSmobile 920DW provided by Filip Lundborg (@filipl) missing-sos.jpg | Generated in GIMP and manually edited by John Reynolds (@quilan1) +missing-frame-image-1410.jpg | Found by @frewsxcv when fuzzing diff --git a/tests/crashtest/images/missing-frame-image-1410.jpg b/tests/crashtest/images/missing-frame-image-1410.jpg new file mode 100644 index 00000000..6bd16966 --- /dev/null +++ b/tests/crashtest/images/missing-frame-image-1410.jpg @@ -0,0 +1 @@ +ÿØÿÙ \ No newline at end of file