Call VariantClear to free BSTR owned by VARIANT instance

This is a minimal fix to reduce leaks of BSTR instances from
QWindowsUiaMainProvider. Introducing a VARIANT wrapper can be done as a
follow-up task.

Task-number: QTBUG-126530
Change-Id: I0c146049644517aca1b6ad7b096833faf5296329
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit a03931095dde102fdfac82e8f6dd874706cadc6f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Jøger Hansegård 2024-06-24 17:59:11 +02:00 committed by Qt Cherry-pick Bot
parent a821bb2d32
commit 46b5edec22

View File

@ -146,6 +146,9 @@ void QWindowsUiaMainProvider::notifyValueChange(QAccessibleValueChangeEvent *eve
clearVariant(&oldVal);
setVariantString(event->value().toString(), &newVal);
UiaRaiseAutomationPropertyChangedEvent(provider, UIA_ValueValuePropertyId, oldVal, newVal);
HRESULT hr = VariantClear(&newVal); // Free string allocated by setVariantString
Q_ASSERT(hr == S_OK);
Q_UNUSED(hr)
}
} else if (QAccessibleValueInterface *valueInterface = accessible->valueInterface()) {
if (QWindowsUiaMainProvider *provider = providerForAccessible(accessible)) {