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

Validate cursor position in UIA UTR ctor #12436

Merged
merged 4 commits into from
Feb 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/types/UiaTextRangeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ HRESULT UiaTextRangeBase::RuntimeClassInitialize(_In_ IUiaData* pData,
_In_ std::wstring_view wordDelimiters) noexcept
try
{
RETURN_HR_IF_NULL(E_INVALIDARG, pData);
RETURN_IF_FAILED(RuntimeClassInitialize(pData, pProvider, wordDelimiters));

// GH#8730: The cursor position may be in a delayed state, resulting in it being out of bounds.
// If that's the case, clamp it to be within bounds.
// TODO GH#12440: We should be able to just check some fields off of the Cursor object,
// but Windows Terminal isn't updating those flags properly.
_start = cursor.GetPosition();
pData->GetTextBuffer().GetSize().Clamp(_start);
_end = _start;

UiaTracing::TextRange::Constructor(*this);
Expand Down