Skip to content

Commit 55a9874

Browse files
zadjii-msftDHowett
authored andcommitted
Fix leak in buffering text for UIA when unfocused (#16251)
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
1 parent a7409ea commit 55a9874

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/renderer/uia/UiaRenderer.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ UiaEngine::UiaEngine(IUiaEventDispatcher* dispatcher) :
4747
[[nodiscard]] HRESULT UiaEngine::Disable() noexcept
4848
{
4949
_isEnabled = false;
50+
51+
// If we had buffered any text from NotifyNewText, dump it. When we do come
52+
// back around to actually paint, we will just no-op. No sense in keeping
53+
// the data buffered.
54+
_newOutput = std::wstring{};
55+
5056
return S_OK;
5157
}
5258

@@ -171,6 +177,10 @@ CATCH_RETURN();
171177
[[nodiscard]] HRESULT UiaEngine::NotifyNewText(const std::wstring_view newText) noexcept
172178
try
173179
{
180+
// GH#16217 - don't even buffer this text if we're disabled. We may never
181+
// come around to write it out.
182+
RETURN_HR_IF(S_FALSE, !_isEnabled);
183+
174184
if (!newText.empty())
175185
{
176186
_newOutput.append(newText);

0 commit comments

Comments
 (0)