89b35d3f
by Marius Kamm at 2026-06-22T18:50:30+02:00
windowscodecs: Fix decoding GIFs that fill the LZW code table.
The GIF LZW decompressor writes a new table entry at index RunningCode-2
for every code while LastCode != NO_SUCH_CODE. Once the table is full,
DGifDecompressInput freezes RunningCode at LZ_MAX_CODE+2, so
RunningCode-2 stays at 4095 and every subsequent code overwrites the
already-valid entry 4095. For a GIF that fills the 4096-entry table and
keeps emitting codes before a clear code, a later code whose prefix
chain runs through the corrupted entry then produces CrntPrefix >
LZ_MAX_CODE / j >= LZ_MAX_CODE, so DGifDecompressLine returns GIF_ERROR
and the whole image fails to load. Native Windows decodes such files
correctly.
Only define a table entry while it is still empty, matching giflib,
which keeps the full table intact until a clear code arrives.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=59887