Skip to content

Expose only largest field in union.fields to prevent ffi-napi size ov…#1

Merged
urbanogilson merged 1 commit into
mainfrom
fix/union-fields-size-overcounting
Apr 4, 2026
Merged

Expose only largest field in union.fields to prevent ffi-napi size ov…#1
urbanogilson merged 1 commit into
mainfrom
fix/union-fields-size-overcounting

Conversation

@urbanogilson
Copy link
Copy Markdown
Member

ffi-napi sums union.fields sizes when determining return value ABI, causing unions to appear larger than they are. On 64-bit x86 Windows this triggers memory corruption when an 8-byte return value is treated as an indirect buffer instead of being returned in a register.

Store all fields in allFields for internal use; set fields to only the largest member so ffi-napi sees the correct size.

Fixes from node-ffi-napi#14 by @shepmaster

…ercounting

ffi-napi sums union.fields sizes when determining return value ABI, causing
unions to appear larger than they are. On 64-bit x86 Windows this triggers
memory corruption when an 8-byte return value is treated as an indirect
buffer instead of being returned in a register.

Store all fields in allFields for internal use; set fields to only the
largest member so ffi-napi sees the correct size.

Bumps version to 1.0.2.

Fixes from node-ffi-napi#14 by @shepmaster
@urbanogilson urbanogilson self-assigned this Apr 4, 2026
@urbanogilson urbanogilson added the bug Something isn't working label Apr 4, 2026
@urbanogilson urbanogilson merged commit dcc8381 into main Apr 4, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant