Skip to content

buffer: fix unaligned UTF-16LE decoding - #65905

Open
mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:fix-buffer-utf16le-odd-length
Open

buffer: fix unaligned UTF-16LE decoding#65905
mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:fix-buffer-utf16le-odd-length

Conversation

@mcollina

@mcollina mcollina commented Sep 8, 2026

Copy link
Copy Markdown
Member

When Buffer.prototype.toString() decoded unaligned UTF-16LE input with an odd byte length, the temporary destination was sized for complete code units while the copy included the trailing byte.

Copy only complete code units, matching the aligned and big-endian paths. Add coverage for stack-backed and heap-backed temporary buffers.

For odd-length input, the destination only has room for complete code
units. Copy those units and ignore the trailing byte. This matches the
aligned and big-endian paths.

Assisted-by: pi
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@nodejs-github-bot nodejs-github-bot added buffer Issues and PRs related to the buffer subsystem. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Sep 8, 2026
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.17%. Comparing base (fe4a42b) to head (ccf1c73).
⚠️ Report is 26 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65905      +/-   ##
==========================================
- Coverage   90.18%   90.17%   -0.02%     
==========================================
  Files         771      771              
  Lines      264911   265097     +186     
  Branches    50309    50353      +44     
==========================================
+ Hits       238919   239046     +127     
- Misses      16966    17005      +39     
- Partials     9026     9046      +20     
Files with missing lines Coverage Δ
src/string_bytes.cc 75.75% <100.00%> (ø)

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gurgunday gurgunday left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@gurgunday gurgunday added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 8, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 8, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@panva panva added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. buffer Issues and PRs related to the buffer subsystem. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants