[PR #5399] UIA: Prevent crash from invalid UTR endpoint comparison #26303

Open
opened 2026-01-31 09:15:13 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/5399

State: closed
Merged: Yes


Summary of the Pull Request

This is a quick-and-easy solution to #5309. If the ITextRangeProvider API allows us to take in two UiaTextRanges, we need to verify that they are both valid.

With this PR, we make sure they both fit in the current TextBuffer. If not, we return E_FAIL. Though this doesn't prove that both UiaTextRanges are from the same TextBuffer, at the very least we don't crash and in cases where we can't make a valid comparison, we return an HRESULT failure.

References

#5406 - This should be the proper solution to this problem. Each UiaTextRange needs to be aware of which TextBuffer it came from.

PR Checklist

Validation Steps Performed

  1. generate enough output to cause the terminal to scroll
  2. execute nano to make us go into the alternate buffer
    This previously crashed, now NVDA seems to detect that there was an error and keeps moving along.
**Original Pull Request:** https://github.com/microsoft/terminal/pull/5399 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request This is a quick-and-easy solution to #5309. If the ITextRangeProvider API allows us to take in two UiaTextRanges, we need to verify that they are both valid. With this PR, we make sure they both fit in the current TextBuffer. If not, we return `E_FAIL`. Though this doesn't prove that both UiaTextRanges are from the same TextBuffer, at the very least we don't crash and in cases where we can't make a valid comparison, we return an HRESULT failure. ## References #5406 - This should be the proper solution to this problem. Each UiaTextRange needs to be aware of which TextBuffer it came from. ## PR Checklist * [X] Closes #5309 ## Validation Steps Performed 1. generate enough output to cause the terminal to scroll 2. execute `nano` to make us go into the alternate buffer This previously crashed, now NVDA seems to detect that there was an error and keeps moving along.
claunia added the pull-request label 2026-01-31 09:15:14 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26303