Skip to content

fix(bindgen): fix utf-8 to utf-16 transcode length calculation - #1840

Merged
vados-cosmonic merged 1 commit into
bytecodealliance:mainfrom
lann:fix-utf-transcoding
Aug 6, 2026
Merged

fix(bindgen): fix utf-8 to utf-16 transcode length calculation#1840
vados-cosmonic merged 1 commit into
bytecodealliance:mainfrom
lann:fix-utf-transcoding

Conversation

@lann

@lann lann commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

This was mistakenly doubling the length of the array view (presumably thinking the Uint16Array length was in bytes). I renamed the var from strlen to codeUnits so that the next person to see it will at least stop and think "what the heck is a code unit?".

This only rarely triggered a real bug; if the destination was near the end of the Memory and/or the string was long enough then it could overflow, triggering RangeError.

@vados-cosmonic vados-cosmonic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 🚀

Thanks or the fix here -- there is an issue out for a UTF16 component test, so I'll try to add that as a follow up at some point

@vados-cosmonic
vados-cosmonic added this pull request to the merge queue Aug 6, 2026
Merged via the queue into bytecodealliance:main with commit f497310 Aug 6, 2026
52 checks passed
@lann
lann deleted the fix-utf-transcoding branch August 6, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants