Skip to content

[rtextures][rlgl] Fix pixel data size regressions#5984

Merged
raysan5 merged 1 commit into
raysan5:masterfrom
GideonSerf:fix-pixel-data-size-regression
Jul 16, 2026
Merged

[rtextures][rlgl] Fix pixel data size regressions#5984
raysan5 merged 1 commit into
raysan5:masterfrom
GideonSerf:fix-pixel-data-size-regression

Conversation

@GideonSerf

@GideonSerf GideonSerf commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Problem

Recent pixel-size hardening added 64-bit variables to safely check image data sizes before converting them to int. Some multiplication operands remain int, so the intermediate calculation may still occur at 32-bit width before assignment.

Explicitly promoting the first operand ensures the calculation consistently uses 64-bit arithmetic across compilers.

ImageRotate() used the total destination image size as its per-pixel stride, causing out-of-bounds access for images larger than one pixel.

Fix

  • Promote pixel-size multiplication operands before evaluation in both GetPixelDataSize() and rlGetPixelDataSize().
  • Keep ImageRotate() allocation size and per-pixel stride as separate values.

Validation

  • Reproduced the ImageRotate() overflow with MSVC AddressSanitizer.
  • Verified large valid and over-limit pixel-size calculations.
  • Verified zero-degree RGBA8 image rotation preserves dimensions and data.
  • Built raylib and all examples with MSVC x64 Release.

@raysan5 raysan5 merged commit a9a0c04 into raysan5:master Jul 16, 2026
16 checks passed
@raysan5

raysan5 commented Jul 16, 2026

Copy link
Copy Markdown
Owner

@GideonSerf Oh! Thanks for the review!

@GideonSerf

Copy link
Copy Markdown
Contributor Author

@raysan5 No problem 😊!

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