Skip to content

Fix JPEG SIMD slicing and padding length handling. #3105

Merged
JimBobSquarePants merged 1 commit intomainfrom
js/fix-3104
Apr 7, 2026
Merged

Fix JPEG SIMD slicing and padding length handling. #3105
JimBobSquarePants merged 1 commit intomainfrom
js/fix-3104

Conversation

@JimBobSquarePants
Copy link
Copy Markdown
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Fix #3104

This PR fixes a potential access violation in the AVX2 Rgb24 unpack path used by JPEG encoding.

UnpackToRgbPlanesAvx2Reduce processes 8 Rgb24 pixels per iteration (24 bytes), but the AVX2 path begins with a 32-byte vector load. On unpadded rows, the final vectorized iteration could therefore read past the end of the source row even though the logical span length checks passed, which matches the crash reported in #3104.

The fix reduces the AVX2 loop count so we only vectorize chunks that still have the 3-pixel slack required by that 32-byte load. Any remaining pixels are left to the existing scalar tail path.

@JimBobSquarePants JimBobSquarePants changed the title Fix SIMD slicing and padding length handling. Fix JPEG SIMD slicing and padding length handling. Apr 7, 2026
@JimBobSquarePants JimBobSquarePants merged commit 043ee2b into main Apr 7, 2026
12 checks passed
@JimBobSquarePants JimBobSquarePants deleted the js/fix-3104 branch April 7, 2026 02:00
JimBobSquarePants added a commit that referenced this pull request Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Access Violation Exception from UnpackToRgbPlanesAvx2Reduce

1 participant