Skip to content

Calculate JPEG2000 total_component_width for each tile in isolation#9704

Merged
radarhere merged 1 commit into
python-pillow:mainfrom
radarhere:jpeg2000
Jun 22, 2026
Merged

Calculate JPEG2000 total_component_width for each tile in isolation#9704
radarhere merged 1 commit into
python-pillow:mainfrom
radarhere:jpeg2000

Conversation

@radarhere

Copy link
Copy Markdown
Member

Within j2k_decode_entry, total_component_width is initialized before the loop through tiles, and is never reset.

int total_component_width = 0;

/* Decode the image tile-by-tile; this means we only need use as much
memory as is required for one tile's worth of components. */
for (;;) {

total_component_width += csize;

This means that the value used in

tile_bytes = tile_width * tile_height * total_component_width;

just keeps growing.

Instead, it should be set to zero within the tile loop, so it is only considering the current tile.

@radarhere radarhere added the JPEG label Jun 21, 2026
@radarhere radarhere merged commit 13ada41 into python-pillow:main Jun 22, 2026
54 checks passed
@radarhere radarhere deleted the jpeg2000 branch June 22, 2026 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant