BUG: prevent nonzero memchr from running out of bounds