Here's a new patch, produced by cannibalizing patch #3644. The framework introduced by the preprocessor macros is a good thing to have now as moves the actual SGR strings in one place and it will be re-used many times by a newer patch #3644.

I am afraid the proposed solution isn't enough to cover
all cases. Tab characters (HT) have the effect of moving
the position without writing spaces in between (as if the
pen or printing head was lifted during the move).

If matches are denoted by <...>, consider this:

.............<..
..>...HT........
.........<..>.

The HT is likely to appear with the background color
of matches when the conditions for running grep are as
you described. Yet, your patch only clears to the end of
line at the very end.

A thorough, if expensive, solution would be to replace
all occurences of "\33[m" (or the wasteful "\33[00m")
by "\33[m\33[K", possibly by defining a preprocessor
macro for it (e.g., SGR_END).

Steps to Reproduce:
1. Open bash in an xterm
2. export GREP_COLOR='1;37;41'
3. export GREP_OPTIONS='--color=auto'
4. press <ENTER> until prompt is on the last line of the xterm
5. grep 'expressions containing' /usr/share/doc/grep-2.5.1/*