Merge pull request #345 from mpospelova/increase-group4reader-height-size

Change Group4Reader height dimension from u16 to u32
This commit is contained in:
Aurelia Molzer authored and GitHub committed 2026-03-03 20:23:52 +00:00
commit 448a0e61d1
3 files changed
+29 -3

No files matched your search

+3 -3
View File
@@ -260,9 +260,9 @@ impl<R: Read> Read for PackBitsReader<R> {
pub struct Group4Reader<R: Read> { pub struct Group4Reader<R: Read> {
decoder: fax34::decoder::Group4Decoder<io::Bytes<io::BufReader<io::Take<R>>>>, decoder: fax34::decoder::Group4Decoder<io::Bytes<io::BufReader<io::Take<R>>>>,
line_buf: io::Cursor<Vec<u8>>, line_buf: io::Cursor<Vec<u8>>,
height: u16, height: u32,
width: u16, width: u16,
y: u16, y: u32,
} }
#[cfg(feature = "fax")] #[cfg(feature = "fax")]
@@ -273,7 +273,7 @@ impl<R: Read> Group4Reader<R> {
compressed_length: u64, compressed_length: u64,
) -> crate::TiffResult<Self> { ) -> crate::TiffResult<Self> {
let width = u16::try_from(dimensions.0)?; let width = u16::try_from(dimensions.0)?;
let height = u16::try_from(dimensions.1)?; let height = dimensions.1;
Ok(Self { Ok(Self {
decoder: fax34::decoder::Group4Decoder::new( decoder: fax34::decoder::Group4Decoder::new(
+26
View File
@@ -720,3 +720,29 @@ fn extra_bits_gray() {
fn extra_bits_rgb() { fn extra_bits_rgb() {
test_image_sum_u8("extra_bits_rgb_8b.tiff", ColorType::RGB(8), 0); test_image_sum_u8("extra_bits_rgb_8b.tiff", ColorType::RGB(8), 0);
} }
#[test]
#[cfg(feature = "fax")]
fn test_decode_huge_g4() {
let path = PathBuf::from(TEST_IMAGE_DIR).join("big_g4.tif");
let img_file = File::open(path).expect("failed to open large G4 test image");
let mut decoder = tiff::decoder::Decoder::new(img_file).expect("failed to create decoder");
let (width, height) = decoder.dimensions().expect("failed to get dimensions");
assert!(
height > u16::MAX as u32,
"Test image height {} is not large enough to test u16 overflow",
height
);
let result = decoder
.read_image()
.expect("failed to decode huge G4 image");
if let tiff::decoder::DecodingResult::U8(data) = result {
assert_eq!(data.len(), (width as usize * height as usize));
} else {
panic!("Unexpected decoding result type");
}
}
Binary file not shown.