Skip to content

Add overflow guard in GetMinSize buffer size calculation#4676

Open
rootvector2 wants to merge 2 commits intolibjxl:mainfrom
rootvector2:getminsize-overflow-check
Open

Add overflow guard in GetMinSize buffer size calculation#4676
rootvector2 wants to merge 2 commits intolibjxl:mainfrom
rootvector2:getminsize-overflow-check

Conversation

@rootvector2
Copy link
Copy Markdown
Contributor

Adds a small overflow check when computing the output buffer size in GetMinSize().

Although earlier dimension checks already limit image sizes, this guard ensures the multiplication and addition used to compute the final buffer size cannot overflow size_t.

This does not change behavior for valid images and simply adds an extra defensive check.

@rootvector2
Copy link
Copy Markdown
Contributor Author

@eustas

@eustas
Copy link
Copy Markdown
Member

eustas commented Mar 26, 2026

Hi. Please consider using SafeAdd and SafeMul added recently (#4685).

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