Repository navigation
BUG: Keep reverse region iterators inside the region after SetIndex - #7069
Merged
hjmjohnson merged 1 commit intoNov 5, 2026
Merged
hjmjohnson merged 1 commit into
hjmjohnson merged 1 commit into
Conversation
hjmjohnson
marked this pull request as ready for review
November 1, 2026 19:57
Contributor
[Medium impact] The PR appears safe to merge; no blocking issues were found.
|
ImageRegionReverseConstIterator set its row span one pixel too far when placed by SetIndex() or built from another iterator: the span began one past the row's last pixel, so the span end landed on the row's first pixel instead of one before it. operator++ then wrapped one pixel early and could walk outside a cropped region; for a region starting at (2, 1) of size (3, 2), stepping back from (4, 2) visited (1, 2) and (0, 2). The converting constructors also computed m_SpanEndOffset in the member initializer list from a not-yet-assigned m_SpanBeginOffset. Compute both offsets in one InitializeSpans() helper, matching GoToBegin().
hjmjohnson
force-pushed
the
bug-reverse-region-span
branch
from
November 1, 2026 23:41
ccce300 to
5ce1939
Compare
dzenanz
approved these changes
Nov 4, 2026
dzenanz
left a comment
Member
There was a problem hiding this comment.
Change looks good on a glance.
Member
Author
|
@greptileai review |
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.
ImageRegionReverseConstIteratorsets its row span one pixel too far when placed withSetIndex()or converted from another iterator, sooperator++can walk outside a cropped region. This computes both span offsets in one helper that matchesGoToBegin(), and adds a test.Found while triaging #7065, where the same formula moved into
InitializeSpans(). The bug is onmainindependently of that PR, so the fix is kept separate to keep #7065 small.Reproduction and test
The test uses a 10 x 4 image and a region starting at
(2, 1)with size(3, 2). It places a reverse iterator at(4, 2), the row's last pixel, and at(3, 2), mid-row, and steps each to the end. Both placements fail onmain.mainSetIndex((4, 2))(4,2) (3,2) (2,2) (1,2) (0,2) (4,1) (3,1)ImageRegionIteratorat(4, 2)(4,2) (3,2) (2,2) (1,2) (4,1) (3,1) (2,1)(4,2) (3,2) (2,2) (4,1) (3,1) (2,1)The span began one past the row's last pixel. That put the span end on the row's first pixel instead of one before it. The converting constructors also computed
m_SpanEndOffsetin the member initializer list from am_SpanBeginOffsetthat had not been assigned yet.With the fix, both paths match the expected order. All 723
ITKCommontests pass on macOS arm64 (clang 19, Release).