Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support valid out-of-bounds access in utextAccess #17361

Merged
merged 1 commit into from
Jun 5, 2024

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Jun 4, 2024

utextAccess apparently doesn't actually need to clamp the
chunkOffset to be in range of the current chunk. Also, I missed to
implement the part of the spec that says to leave the iterator on the
first/last chunk of the UText in case of an out-of-bounds index.

This PR fixes the issue by simply not returning early, doing a more
liberal clamp of the offset, and then checking whether it was in range.

As an aside, this also fixes a one-off bug when hovering URLs that
end on the very last cell of the viewport (or are cut off).

Closes #17343

Validation Steps Performed

  • Write an URL that wraps across the last 2 lines in the buffer
  • Scroll 1 line up
  • No assert ✅
  • Hovering the URL shows the full, still visible parts of the URL ✅

auto neededIndex = nativeIndex;
// This will make it simpler for us to search the row that contains the nativeIndex,
// because we'll now only need to check for `start<=index<limit` and nothing else.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduce your diff NOW by applying the patented whitespace-reduction to your browser: https://github.com/microsoft/terminal/pull/17361/files?w=1
Results may vary.

@lhecker lhecker added this pull request to the merge queue Jun 5, 2024
Merged via the queue into main with commit 261a3fe Jun 5, 2024
20 checks passed
@lhecker lhecker deleted the dev/lhecker/17343-fix-assert branch June 5, 2024 17:48
DHowett pushed a commit that referenced this pull request Jun 7, 2024
`utextAccess` apparently doesn't actually need to clamp the
`chunkOffset` to be in range of the current chunk. Also, I missed to
implement the part of the spec that says to leave the iterator on the
first/last chunk of the `UText` in case of an out-of-bounds index.

This PR fixes the issue by simply not returning early, doing a more
liberal clamp of the offset, and then checking whether it was in range.

As an aside, this also fixes a one-off bug when hovering URLs that
end on the very last cell of the viewport (or are cut off).

Closes #17343

## Validation Steps Performed
* Write an URL that wraps across the last 2 lines in the buffer
* Scroll 1 line up
* No assert ✅
* Hovering the URL shows the full, still visible parts of the URL ✅

(cherry picked from commit 261a3fe)
Service-Card-Id: 92678595
Service-Version: 1.20
DHowett pushed a commit that referenced this pull request Jun 7, 2024
`utextAccess` apparently doesn't actually need to clamp the
`chunkOffset` to be in range of the current chunk. Also, I missed to
implement the part of the spec that says to leave the iterator on the
first/last chunk of the `UText` in case of an out-of-bounds index.

This PR fixes the issue by simply not returning early, doing a more
liberal clamp of the offset, and then checking whether it was in range.

As an aside, this also fixes a one-off bug when hovering URLs that
end on the very last cell of the viewport (or are cut off).

Closes #17343

## Validation Steps Performed
* Write an URL that wraps across the last 2 lines in the buffer
* Scroll 1 line up
* No assert ✅
* Hovering the URL shows the full, still visible parts of the URL ✅

(cherry picked from commit 261a3fe)
Service-Card-Id: 92678596
Service-Version: 1.21
@lhecker lhecker added the Issue-Bug It either shouldn't be doing this or needs an investigation. label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation.
Projects
Development

Successfully merging this pull request may close these issues.

regex search occasionally hits bounds assert in UTextAdapter
3 participants