Repository navigation
Fix out-of-bounds read in wavelet decomposition on small images (e.g., thumbnails) - #21461
Merged
Merged
Conversation
Collaborator
Author
|
@TurboGit also in this case, I tentatively set 5.6.1 as the milestone. The bug is not 5.6-related, but the change is a genuine bugfix. |
TurboGit
approved these changes
Jun 30, 2026
TurboGit
left a comment
Member
There was a problem hiding this comment.
Thanks! I'll merge on master for now and if regression tests are clean tomorrow and my testing later today is good I'll merge for 5.6.1.
Collaborator
|
Just checked integration tests also for OpenCL with just-now commits. All good. |
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.
Problem
The à trous wavelet decomposition in
common/dwt.caverages each pixel with neighbourshscalepixels to the left/right (and rows above/below), wherehscaledoubles each scale level. At the borders, out-of-range neighbours are reflected back inside using2*width-2-(col+hscale).The horizontal pass capped the scale at
MIN(1 << lev, width). Whenhscalereacheswidth— a small image (e.g. thumbnail/mipmap export) combined with a high wavelet level — the reflection of the last column underflows to-1. Since the index is an unsignedsize_t, it wraps to a huge value and the code reads gigabytes past the buffer →SIGSEGV.This reliably crashed retouch during thumbnail export (
_image_load_job_run→ pixelpipe → retouch →dwt_decompose). The vertical pass already capped correctly atheight-1; the horizontal pass did not.Fix
dwt_decompose_horiz: caphscaleatwidth-1, mirroring the vertical pass.dwt_denoise_vert_1ch/dwt_denoise_horiz_1ch: samesize-1cap. The horizontal denoise kernel additionally used three disjoint loops that overlap and double-process columns when2*hscale > width; reworked the loop bounds into a true non-overlapping partition and reflected the far neighbour in the edge loop. The hot middle loop keeps its vectorized form.dwt.cl+ host): clampscatsize-1and reflect the far neighbour in the left/top kernel branches, matching the CPU path.Behaviour is unchanged in the valid range (
hscale < width); only the previously-crashing over-scaled case now produces a well-defined max-reflection result.macOS crash report
crash_report.txt
Co-authored with Claude.