Skip to content

Fix GaussianBlur crash on grayscale images - #880

Merged
kean merged 1 commit into
kean:mainfrom
Delarkz:fix-gaussianblur-grayscale-crash
Aug 2, 2026
Merged

Fix GaussianBlur crash on grayscale images#880
kean merged 1 commit into
kean:mainfrom
Delarkz:fix-gaussianblur-grayscale-crash

Conversation

@Delarkz

@Delarkz Delarkz commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

ImageProcessors.GaussianBlur crashes (SIGSEGV) on grayscale (monochrome) images like black-and-white JPEGs. It shows up on iOS and tvOS; on macOS the same out-of-bounds write happens but usually corrupts memory silently instead of faulting.

vImageBoxConvolve_ARGB8888 assumes 4 bytes per pixel, but the scratch contexts were created with the source's own color space. For a grayscale image that's a 16-bit gray+alpha buffer (2 bytes per pixel), so vImage ends up reading and writing past the end of the allocation.

The fix creates the scratch contexts in device RGB so the buffer layout matches what vImage expects (drawing a gray image into an RGB context is lossless).

@kean

kean commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Nice catch, thank you!

@kean
kean merged commit 10a9b48 into kean:main Aug 2, 2026
5 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