Skip to content

Commit

Permalink
Fix leak in buffering text for UIA when unfocused (#16251)
Browse files Browse the repository at this point in the history
Notes in #16217 have the investigation.

TL;DR: we'd always buffer text. Even if we're disabled (unfocused). When
we're
disabled, we'd _never_ clear the buffered text. Oops.

Closes #16217

(cherry picked from commit d14524c)
Service-Card-Id: 91033138
Service-Version: 1.19
  • Loading branch information
zadjii-msft authored and DHowett committed Nov 13, 2023
1 parent a7409ea commit 55a9874
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/renderer/uia/UiaRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ UiaEngine::UiaEngine(IUiaEventDispatcher* dispatcher) :
[[nodiscard]] HRESULT UiaEngine::Disable() noexcept
{
_isEnabled = false;

// If we had buffered any text from NotifyNewText, dump it. When we do come
// back around to actually paint, we will just no-op. No sense in keeping
// the data buffered.
_newOutput = std::wstring{};

return S_OK;
}

Expand Down Expand Up @@ -171,6 +177,10 @@ CATCH_RETURN();
[[nodiscard]] HRESULT UiaEngine::NotifyNewText(const std::wstring_view newText) noexcept
try
{
// GH#16217 - don't even buffer this text if we're disabled. We may never
// come around to write it out.
RETURN_HR_IF(S_FALSE, !_isEnabled);

if (!newText.empty())
{
_newOutput.append(newText);
Expand Down

0 comments on commit 55a9874

Please sign in to comment.