Skip to content

Bound memory use in lossless WebP decoding - #211

Open
advolkov wants to merge 1 commit into
image-rs:mainfrom
advolkov:fix/issue-197-huffman-memory
Open

advolkov wants to merge 1 commit into
image-rs:mainfrom
advolkov:fix/issue-197-huffman-memory

Conversation

@advolkov

Copy link
Copy Markdown

This change remaps used Huffman groups to a small range. Unused groups are checked, but their tables are not kept. Lossless, ALPH, VP8, and animation canvas buffers share one memory limit.
The limit excludes input data, the caller output buffer, and allocator overhead.

I used a small temporary script to measure peak heap use during read_image. The input file and output buffer were not counted.

  • Main branch: 18,350,086 bytes
  • This branch: 290 bytes

Closes #197

@advolkov advolkov changed the title fix: limit memory use in lossless WebP decoding Bound memory use in lossless WebP decoding Nov 12, 2026
@advolkov
advolkov force-pushed the fix/issue-197-huffman-memory branch from 7e77571 to 42a2381 Compare November 12, 2026 20:34
@advolkov
advolkov force-pushed the fix/issue-197-huffman-memory branch from 42a2381 to 9707794 Compare November 15, 2026 17:52
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.

Lossless decoder: Huffman group count is unbounded by image size (memory amplification)

1 participant