Anonymous committed 1f5b9cc

grep: fix colouring of matches with zero length

If a zero-length match is encountered, break out of loop and show the rest
of the line uncoloured. Otherwise we'd be looping forever, trying to make
progress by advancing the pointer by zero characters.

Signed-off-by: Rene Scharfe <>
Signed-off-by: Junio C Hamano <>

  • Participants
  • Parent commits dbb6a4a

Comments (0)

Files changed (1)

 		*eol = '\0';
 		while (next_match(opt, bol, eol, ctx, &match, eflags)) {
+			if (match.rm_so == match.rm_eo)
+				break;
 			       (int)match.rm_so, bol,