grep: fix two bugs found by hwasan.

The first bug appeared as a memory overwrite, but was actually visible
without hwasan: basically any `grep -F` that let to multiple matches on
the same line was broken.

The second bug was another memory overwrite, visible when I ran the
existing grep tests.

Bug: http://b/137573082
2 files changed