Skip to content

Commit ea51ee2

Browse files
author
HeroicKatora
authored
Merge pull request #166 from okaneco/dedup-check
Consolidate planes check in decoder.rs
2 parents 152acff + fa6ff69 commit ea51ee2

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/decoder.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,6 @@ impl<R: Read> Decoder<R> {
371371
previous_marker = marker;
372372
}
373373

374-
if planes.is_empty() || planes.iter().any(|plane| plane.is_empty()) {
375-
return Err(Error::Format("no data found".to_owned()));
376-
}
377-
378374
let frame = self.frame.as_ref().unwrap();
379375
compute_image(&frame.components, planes, frame.output_size, self.is_jfif, self.color_transform)
380376
}
@@ -806,7 +802,7 @@ fn compute_image(components: &[Component],
806802
output_size: Dimensions,
807803
is_jfif: bool,
808804
color_transform: Option<AdobeColorTransform>) -> Result<Vec<u8>> {
809-
if data.iter().any(Vec::is_empty) {
805+
if data.is_empty() || data.iter().any(Vec::is_empty) {
810806
return Err(Error::Format("not all components have data".to_owned()));
811807
}
812808

0 commit comments

Comments
 (0)