Skip to content

Commit

Permalink
Fix leak in buffering text for UIA when unfocused (microsoft#16251)
Browse files Browse the repository at this point in the history
Notes in microsoft#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 microsoft#16217
  • Loading branch information
zadjii-msft authored Nov 10, 2023
1 parent e268c1c commit d14524c
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 d14524c

Please sign in to comment.