buffer: fix end parameter bugs in indexOf/lastIndexOf · nodejs/node@49198d2 · GitHub
Skip to content

Commit 49198d2

Browse files
ronagaduh95
authored andcommitted
buffer: fix end parameter bugs in indexOf/lastIndexOf
- 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> Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> PR-URL: #62711 Fixes: #62873 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 9f5bf55 commit 49198d2

2 files changed

Lines changed: 50 additions & 11 deletions

File tree

src/node_buffer.cc

Lines changed: 15 additions & 11 deletions

test/parallel/test-buffer-indexof.js

Lines changed: 35 additions & 0 deletions

0 commit comments

Comments
 (0)