Repository navigation
Fix JPEG screenshots crashing on 64-bit builds - #216
Merged
Merged
Conversation
SCR_ScreenShot passes the bottom row and a negative width so the image is written top-down. In Image_WriteJPEG, cinfo.next_scanline is an unsigned JDIMENSION, so next_scanline*width*3 is computed as unsigned: on 32-bit Windows the wrapped value lands on the right address, but on LP64 builds (Linux, macOS) it indexes about 4 GB past the buffer and the screenshot crashes in jpeg_write_scanlines. Cast to int so the offset is signed, as the PNG writer already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SCR_ScreenShotpassesImage_WriteJPEGthe bottom row and a negative width, so the image is written top-down. The row offset is computed ascinfo.next_scanlineis an unsignedJDIMENSION, so the whole product is unsigned. On 32-bit Windows the wrapped value still lands on the right address. On LP64 builds (Linux and macOS, x86-64 or arm64) it zero-extends to an index about 4 GB past the buffer, andscreenshotcrashes insidejpeg_write_scanlines:The fix casts
next_scanlinetoint, so the offset is signed, which is howImage_WritePNGalready does it. Windows 32-bit behaviour is unchanged.Tested on an arm64 macOS build of current
master: before the fixscreenshotcrashed every time; after it the JPEG is written correctly, both windowed (800×600) and fullscreen (3840×1620).🤖 Generated with Claude Code