Skip to content

buffer: fix end parameter bugs in indexOf/lastIndexOf#62711

Open
ronag wants to merge 1 commit intonodejs:mainfrom
ronag:buffer-index-of-end2
Open

buffer: fix end parameter bugs in indexOf/lastIndexOf#62711
ronag wants to merge 1 commit intonodejs:mainfrom
ronag:buffer-index-of-end2

Conversation

@ronag
Copy link
Copy Markdown
Member

@ronag ronag commented Apr 12, 2026

  • Fix FastIndexOfNumber parameter order mismatch (end_i64 and is_forward were swapped vs the JS call site and slow path)
  • Clamp negative end values to 0 to prevent size_t overflow in IndexOfString, IndexOfBuffer, and IndexOfNumberImpl
  • Clamp empty needle result to search_end

@ronag ronag requested review from jasnell and mcollina April 12, 2026 20:18
@ronag ronag added the buffer Issues and PRs related to the buffer subsystem. label Apr 12, 2026
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Apr 12, 2026
@ronag ronag added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 12, 2026
@ronag ronag force-pushed the buffer-index-of-end2 branch from cb18a94 to 81afd27 Compare April 12, 2026 20:25
- Fix FastIndexOfNumber parameter order mismatch (end_i64 and
  is_forward were swapped vs the JS call site and slow path)
- Clamp negative end values to 0 to prevent size_t overflow in
  IndexOfString, IndexOfBuffer, and IndexOfNumberImpl
- Clamp empty needle result to search_end

Signed-off-by: Robert Nagy <ronagy@icloud.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ronag ronag force-pushed the buffer-index-of-end2 branch from 81afd27 to 927c25a Compare April 12, 2026 20:28
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.81%. Comparing base (4563cb3) to head (927c25a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62711      +/-   ##
==========================================
+ Coverage   88.93%   89.81%   +0.87%     
==========================================
  Files         699      699              
  Lines      216379   216383       +4     
  Branches    41281    41369      +88     
==========================================
+ Hits       192434   194341    +1907     
+ Misses      15976    14134    -1842     
+ Partials     7969     7908      -61     
Files with missing lines Coverage Δ
src/node_buffer.cc 68.72% <100.00%> (+0.69%) ⬆️

... and 104 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. request-ci Add this label to start a Jenkins CI on a PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants