Skip to content

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

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
mcollina:fix-buffer-utf16le-odd-length
Sep 10, 2026
Merged

buffer: fix unaligned UTF-16LE decoding#65905
nodejs-github-bot merged 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 61 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
@ronag ronag added the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 8, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Sep 10, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Commit Queue failed

GitHub failed to squash and merge this pull request.

The pull request was removed from the Commit Queue and labeled commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. . After resolving the failure, remove that label and add commit-queue PRs queued for automated landing through the Commit Queue. to retry.

Full Commit Queue output
- Loading data for nodejs/node/pull/65905
✔  Done loading data for nodejs/node/pull/65905
----------------------------------- PR info ------------------------------------
Title      buffer: fix unaligned UTF-16LE decoding (#65905)
Author     Matteo Collina <matteo.collina@gmail.com> (@mcollina)
Branch     mcollina:fix-buffer-utf16le-odd-length -> nodejs:main
Labels     buffer, c++, author ready, needs-ci, commit-queue
Commits    1
 - buffer: fix unaligned UTF-16LE decoding
Committers 1
 - Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/65905
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/65905
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Tue, 08 Sep 2026 06:44:52 GMT
   ✔  Approvals: 3
   ✔  - Gürgün Dayıoğlu (@gurgunday): https://github.com/nodejs/node/pull/65905#pullrequestreview-5141170565
   ✔  - Filip Skokan (@panva) (TSC): https://github.com/nodejs/node/pull/65905#pullrequestreview-5141847462
   ✔  - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/65905#pullrequestreview-5146517461
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2026-09-08T11:42:34Z: https://ci.nodejs.org/job/node-test-pull-request/77189/
- Querying data for job/node-test-pull-request/77189/
✔  Build data downloaded
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  No git cherry-pick in progress
   ✔  No git am in progress
   ✔  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
✔  origin/main is now up-to-date
- Downloading patch for 65905
From https://github.com/nodejs/node
 * branch                  refs/pull/65905/merge -> FETCH_HEAD
✔  Fetched commits as e026733cd068..ccf1c73a2663
--------------------------------------------------------------------------------
[main ae513b71eb] buffer: fix unaligned UTF-16LE decoding
 Author: Matteo Collina <hello@matteocollina.com>
 Date: Mon Sep 7 18:37:50 2026 +0200
 2 files changed, 9 insertions(+), 2 deletions(-)
   ✔  Patches applied
--------------------------------------------------------------------------------
--------------------------------- New Message ----------------------------------
buffer: fix unaligned UTF-16LE decoding

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>
PR-URL: https://github.com/nodejs/node/pull/65905
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
--------------------------------------------------------------------------------
[main 120fd7a52d] buffer: fix unaligned UTF-16LE decoding
 Author: Matteo Collina <hello@matteocollina.com>
 Date: Mon Sep 7 18:37:50 2026 +0200
 2 files changed, 9 insertions(+), 2 deletions(-)
  ✔  120fd7a52d55f9bced960d3b5bed614b55c6eda9
     ✔  0:0      Assisted-by is a trailer                  assisted-by-is-trailer
     ✔  0:0      no Co-authored-by metadata                co-authored-by-is-trailer
     ✔  0:0      skipping fixes-url                        fixes-url
     ✔  0:0      blank line after title                    line-after-title
     ✔  0:0      line-lengths are valid                    line-length
     ✔  0:0      metadata is at end of message             metadata-end
     ✔  7:8      PR-URL is valid.                          pr-url
     ✔  0:0      reviewers are valid                       reviewers
     ✔  0:0      has valid Signed-off-by                   signed-off-by
     ✔  0:0      valid subsystems                          subsystem
     ✔  0:0      Title is formatted correctly.             title-format
     ✔  0:0      Title is <= 50 columns.                   title-length
--------------------------------------------------------------------------------
The following commits are landable on origin/main
- 120fd7a52d buffer: fix unaligned UTF-16LE decoding
--------------------------------------------------------------------------------
- Removing temporary files
✔  Temporary files removed.
To finish landing:
1. Run: 
   git push origin main
2. Post "Landed in 120fd7a52d55" in https://github.com/nodejs/node/pull/65905
   gh pr comment https://github.com/nodejs/node/pull/65905 --body "Landed in 120fd7a52d55"
   gh pr close https://github.com/nodejs/node/pull/65905
gh: Server Error (HTTP 502)

View workflow run

@panva panva added commit-queue PRs queued for automated landing through the Commit Queue. and removed commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. labels Sep 10, 2026
@nodejs-github-bot
nodejs-github-bot merged commit b805fb5 into nodejs:main Sep 10, 2026
99 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in b805fb5

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 10, 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.

5 participants