Skip to content

Fix SIGSEGV crash in EventTarget::getTag() when instanceHandle is null#56212

Open
matthewlevy97 wants to merge 1 commit intofacebook:mainfrom
matthewlevy97:export-D96473264
Open

Fix SIGSEGV crash in EventTarget::getTag() when instanceHandle is null#56212
matthewlevy97 wants to merge 1 commit intofacebook:mainfrom
matthewlevy97:export-D96473264

Conversation

@matthewlevy97
Copy link

Summary:
Changelog:
[General][Fixed] - Fix crash in EventTarget when instanceHandle is null

This fixes a null pointer dereference crash in EventTarget::getTag() that occurs when instanceHandle_ is null. The crash was observed in UIManagerBinding::dispatchEventToJS() when dispatching events to JS.

The EventTarget can be constructed with a null instanceHandle (as evidenced by test code and production usage), but getTag() and retain() were dereferencing it without checking for null first.

This change adds defensive null checks in:

  1. EventTarget::getTag() - returns -1 (invalid tag) if instanceHandle_ is null
  2. EventTarget::retain() - skips getting instance handle if instanceHandle_ is null

This follows the existing pattern used in ShadowNodeFamily::getInstanceHandle() which already handles the null instanceHandle_ case.

Reviewed By: javache

Differential Revision: D96473264

Summary:
Changelog:
[General][Fixed] - Fix crash in EventTarget when instanceHandle is null

This fixes a null pointer dereference crash in EventTarget::getTag() that occurs when instanceHandle_ is null. The crash was observed in UIManagerBinding::dispatchEventToJS() when dispatching events to JS.

The EventTarget can be constructed with a null instanceHandle (as evidenced by test code and production usage), but getTag() and retain() were dereferencing it without checking for null first.

This change adds defensive null checks in:
1. EventTarget::getTag() - returns -1 (invalid tag) if instanceHandle_ is null
2. EventTarget::retain() - skips getting instance handle if instanceHandle_ is null

This follows the existing pattern used in ShadowNodeFamily::getInstanceHandle() which already handles the null instanceHandle_ case.

Reviewed By: javache

Differential Revision: D96473264
@meta-codesync
Copy link

meta-codesync bot commented Mar 24, 2026

@matthewlevy97 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D96473264.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant