Fix divide by zero bug

This fixes #33
This commit is contained in:
Birk Tjelmeland committed 2019-04-25 14:58:08 +02:00
1 parent f7850ad5bd
commit dbf532b0a9
51 files changed
+13

No files matched your search

+4
View File
@@ -612,6 +612,10 @@ impl<R: Read + Seek> Decoder<R> {
.get_tag_u32(ifd::Tag::RowsPerStrip)
.unwrap_or(self.height);
if rows_per_strip == 0 {
return Ok(0);
}
Ok((self.height + rows_per_strip - 1) / rows_per_strip)
}
+9
View File
@@ -40,3 +40,12 @@ fn inf_loop() {
true
});
}
// https://github.com/image-rs/image-tiff/issues/33
#[test]
fn divide_by_zero() {
test_directory("./tests/fuzz_images/divide_by_zero", |file| {
decode_tiff(file).ok();
true
});
}