buffer: fix UCS2 indexOf for odd buffer length · nodejs/node@9cd14ce · GitHub
Skip to content

Commit 9cd14ce

Browse files
addaleaxevanlucas
authored andcommitted
buffer: fix UCS2 indexOf for odd buffer length
Fix `buffer.indexOf` for the case that the haystack has odd length and the needle is not found in it. `StringSearch()` would return the length of the buffer in multiples of `sizeof(uint16_t)`, but checking that against `haystack_length` would not work if the latter one was odd. PR-URL: #6511 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
1 parent a550ddb commit 9cd14ce

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/node_buffer.cc

Lines changed: 3 additions & 1 deletion

test/parallel/test-buffer-indexof.js

Lines changed: 3 additions & 0 deletions

0 commit comments

Comments
 (0)