Skip to content

[0.82] fix: null dereference in get_SelectionContainer when no selection container exists#16113

Merged
microsoft-github-policy-service[bot] merged 1 commit into0.82-stablefrom
82null
May 11, 2026
Merged

[0.82] fix: null dereference in get_SelectionContainer when no selection container exists#16113
microsoft-github-policy-service[bot] merged 1 commit into0.82-stablefrom
82null

Conversation

@vineethkuttan
Copy link
Copy Markdown
Contributor

@vineethkuttan vineethkuttan commented May 11, 2026

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Why

get_SelectionContainer (UIA SelectionItemPattern.SelectionContainer) crashes with a null dereference when the element has no ancestor with a selection container. GetSelectionContainer() walks the parent tree looking for a view with multiselectable and required props set; if none is found it returns nullptr, which was immediately dereferenced on the next line.

What

  • Added a null check on the return value of GetSelectionContainer() in get_SelectionContainer
  • Returns S_OK with *pRetVal == nullptr when no container is found — correct per UIA spec (element is simply not inside a selection container)
auto selectionContainerView = GetSelectionContainer();
// Per UIA spec, returning S_OK with *pRetVal == nullptr is correct when the element
// is not contained within a selection container.
if (!selectionContainerView)
  return S_OK;

Screenshots

N/A

Testing

Reproduced by calling get_SelectionContainer on a selection item whose ancestor tree contains no multiselectable container. Verified the null check prevents the crash and returns S_OK with a null provider pointer.

Changelog

Should this change be included in the release notes: yes

Fix crash (null dereference) in UIA SelectionItemPattern.get_SelectionContainer when the element has no selection

Microsoft Reviewers: Open in CodeFlow

…tainer exists (#16091)

* fix: null dereference in get_SelectionContainer when no container found

Agent-Logs-Url: https://github.com/microsoft/react-native-windows/sessions/dee66731-6253-459a-8ba1-f733d5bee554

Co-authored-by: vineethkuttan <66076509+vineethkuttan@users.noreply.github.com>

* Change files

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: vineethkuttan <66076509+vineethkuttan@users.noreply.github.com>
@vineethkuttan vineethkuttan requested a review from a team as a code owner May 11, 2026 00:51
@vineethkuttan vineethkuttan changed the title fix: null dereference in get_SelectionContainer when no selection container exists [0.82] fix: null dereference in get_SelectionContainer when no selection container exists May 11, 2026
@vineethkuttan vineethkuttan added the AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity) label May 11, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot enabled auto-merge (squash) May 11, 2026 01:16
Copy link
Copy Markdown
Contributor

@iamAbhi-916 iamAbhi-916 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@microsoft-github-policy-service microsoft-github-policy-service Bot merged commit 9bb8f2a into 0.82-stable May 11, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants