https://github.com/gwsw/less/commit/8320d1a920a90599892b9aca2306822709dab8f7
diff --git a/search.c b/search.c
index 758e4491..98f01e5f 100644
--- a/search.c
+++ b/search.c
@@ -944,6 +944,8 @@ static void hilite_line(POSITION linepos, char *line, int line_len, int *chpos,
 	do {
 		char *lep = sp[0];
 		int i;
+		if (sp[0] == NULL || ep[0] == NULL)
+			break;
 		for (i = 1;  i < nsp;  i++)
 		{
 			if (sp[i] == NULL || ep[i] == NULL)
