Skip to content

test: regression tests for small interlaced GIF decode failure#232

Open
lilith wants to merge 1 commit intoimage-rs:masterfrom
lilith:fix/small-interlaced-truncation
Open

test: regression tests for small interlaced GIF decode failure#232
lilith wants to merge 1 commit intoimage-rs:masterfrom
lilith:fix/small-interlaced-truncation

Conversation

@lilith
Copy link
Copy Markdown
Contributor

@lilith lilith commented Apr 13, 2026

Three valid interlaced GIFs produced by gifsicle 1.95 are rejected with "image truncated". All decode correctly with giftopnm (netpbm).

File Size Dimensions Error
7x7 grayscale 39 bytes 7x7 image truncated
9x9 bilevel 71 bytes 9x9 image truncated
47x63 grayscale 149 bytes 47x63 image truncated

Root cause: when decoding interlaced frames, read_into_buffer passes per-row slices to the LZW decoder. For small images (7-47 byte rows), weezl returns NoProgress because the output buffer is too small for its internal state machine to advance. The gif crate mishandles this by either skipping input data or treating it as end-of-stream.

Related: image-rs/weezl#72

This PR adds only failing tests — no fix included. The three test GIFs are inlined as byte arrays (39-149 bytes each).

Three valid interlaced GIFs (7x7, 9x9, 47x63) produced by gifsicle 1.95
are rejected with "image truncated". All decode correctly with giftopnm
(netpbm) and are valid per the GIF89a spec.

Root cause: when decoding interlaced frames, read_into_buffer passes
per-row slices to the LZW decoder. For small images (7-47 byte rows),
weezl's NoProgress status triggers two bugs in DecodeSubBlock:
1. Input data is skipped instead of retried with a smaller buffer
2. NoProgress during flush is treated as end-of-stream

Related: image-rs/weezl#72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant