Unverified Commit bc8b5254 authored by Anna Henningsen's avatar Anna Henningsen
Browse files

buffer: fix lastIndexOf index underflow issue

Fix `buffer.lastIndexOf()` for the case that the first character
of the needle is contained in the haystack, but in a location that
makes it impossible to be part of a full match.

For example, when searching for 'abc' in 'abcdef', only the 'cdef'
part needs to be searched for 'c', because earlier locations can
be excluded by index calculations alone.

Previously, such a search would result in an assertion failure.

This applies only to Node.js v6, as `lastIndexOf` was added in it.

PR-URL: https://github.com/nodejs/node/pull/6511


Reviewed-By: default avatarJames M Snell <jasnell@gmail.com>
Reviewed-By: default avatarTrevor Norris <trev.norris@gmail.com>
parent 55b975d4
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment