
< 	for (p = s;  p < s + slen;  p++)
---
> 	for (p = s; p - s < slen && p < s + slen; p++)
