Skip to content

use size_t for image plane allocation in alloc_image#635

Merged
solidpixel merged 2 commits into
ARM-software:mainfrom
sahvx655-wq:size_t-image-plane-alloc
Jun 3, 2026
Merged

use size_t for image plane allocation in alloc_image#635
solidpixel merged 2 commits into
ARM-software:mainfrom
sahvx655-wq:size_t-image-plane-alloc

Conversation

@sahvx655-wq
Copy link
Copy Markdown
Contributor

alloc_image sizes each plane with dim_x * dim_y * 4 evaluated as unsigned int, but those dimensions come straight from a .astc or .ktx header, so a 32768x32768 image wraps the multiply and allocates a 0 byte plane. The decompressor then writes the full 4dim_xdim_y extent with size_t indexing in store_image_block and runs off the end of the buffer. I hit this reading the alloc path after the recent surface-size fixes: the KTX and DDS loaders check the size in 64-bit but the allocation here was still 32-bit, and the decompress output path has no guard at all. Widen the multiply to size_t so the buffer matches what gets written.

@solidpixel solidpixel self-requested a review June 3, 2026 21:06
@solidpixel
Copy link
Copy Markdown
Contributor

Good spot, thank you.

@solidpixel solidpixel merged commit 4afa847 into ARM-software:main Jun 3, 2026
9 checks passed
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.

2 participants