Fix memory leak in _getIA2TargetsForRelationsOfType.#20207
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue number:
None.
Summary of the issue:
NVDAObjects.IAccessible.IAccessible._getIA2TargetsForRelationsOfTypecalls IAccessible2_2::relationTargetsOfType, a COM method which returns a server-allocated array. Per COM rules and the IAccessible2 documentation, this array must be freed with CoTaskMemFree. However, comtypes doesn't have sufficient information to know that it must be freed, nor do we explicitly free it ourselves. Thus, we are leaking memory every time we call this and it returns a relation.Note that we already call CoTaskMemFree for IAccessibleTableCell::row/columnHeaderCells, which is a similar COM method. See
NVDAObjects.IAccessible.IAccessible._tableHeaderTextHelper.Description of user facing changes:
Fixes a memory leak. However, I don't think this is worth noting in the What's New, since it's probably not significant enough for most users to notice.
Description of development approach:
Use try/finally after the COM method call. Call CoTaskMemFree in the finally block.
Testing strategy:
data:text/html,<button aria-details="d">b</button><div id="d">dNote that this can't currently be tested in Firefox, as NVDA details reporting is broken in focus mode in Firefox. However, that is an existing bug, not one introduced by this PR.
Known issues with pull request:
None.
Code Review Checklist: