fix search past the end of haystack in memmem
authorTimo Teräs <timo.teras@iki.fi>
Thu, 10 Apr 2014 01:06:17 +0000 (21:06 -0400)
committerRich Felker <dalias@aerifal.cx>
Wed, 16 Apr 2014 06:46:05 +0000 (02:46 -0400)
commit043865cadf1b26ee3a9ccdac3b0d0ca9d380cdad
treef810d1e6fa1d2f2eb88eceec1501e0a3ded58ecc
parenta65824a74fc49b059ecd684a9edba31070a1794f
fix search past the end of haystack in memmem

to optimize the search, memchr is used to find the first occurrence of
the first character of the needle in the haystack before switching to
a search for the full needle. however, the number of characters
skipped by this first step were not subtracted from the haystack
length, causing memmem to search past the end of the haystack.

(cherry picked from commit 6fbdeff0e51f6afc38fbb1476a4db81322779da4)
src/string/memmem.c