Commit 12a9699
buffer: fix needle length misestimation for UCS2
Use `StringBytes::Size` to determine the needle string length
instead of assuming latin-1 or UTF-8.
Previously, `Buffer.indexOf` could fail with an assertion failure
when the needle's byte length, but not its character count,
exceeded the haystack's byte length.
PR-URL: #6511
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>1 parent 7b60b8f commit 12a9699Copy full SHA for 12a9699
File tree
Expand file treeCollapse file tree
2 files changed
+8
-2
lines changedOpen diff view settings
Filter options
- src
- test/parallel
Expand file treeCollapse file tree
2 files changed
+8
-2
lines changedOpen diff view settings
Collapse file
+2-2Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
827 | 827 | |
828 | 828 | |
829 | 829 | |
830 | | - |
| 830 | + |
831 | 831 | |
832 | | - |
| 832 | + |
833 | 833 | |
834 | 834 | |
835 | 835 | |
|
Collapse file
test/parallel/test-buffer-indexof.js
Copy file name to clipboardExpand all lines: test/parallel/test-buffer-indexof.js+6Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
233 | 233 | |
234 | 234 | |
235 | 235 | |
| 236 | + |
| 237 | + |
| 238 | + |
| 239 | + |
| 240 | + |
| 241 | + |
236 | 242 | |
237 | 243 | |
238 | 244 | |
|
0 commit comments