patch 9.1.1185: endless loop with completefuzzycollect and no match found

Problem:  endless loop with completefuzzycollect and no match found
Solution: move pointer to line end and break loop

closes: #16820

Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/search.c b/src/search.c
index 67082a7..654b896 100644
--- a/src/search.c
+++ b/src/search.c
@@ -5229,8 +5229,7 @@
  * - `*len` is set to the length of the matched word.
  * - `*score` contains the match score.
  *
- * If no match is found, `*ptr` is updated to point beyond the last word
- * or to the end of the line.
+ * If no match is found, `*ptr` is updated to to the end of the line.
  */
     int
 fuzzy_match_str_in_line(
@@ -5246,11 +5245,13 @@
     char_u	*start = NULL;
     int		found = FALSE;
     char	save_end;
+    char_u	*line_end = NULL;
 
     if (str == NULL || pat == NULL)
         return found;
+    line_end = find_line_end(str);
 
-    while (*str != NUL)
+    while (str < line_end)
     {
 	// Skip non-word characters
 	start = find_word_start(str);
@@ -5283,6 +5284,9 @@
 	    MB_PTR_ADV(str);
     }
 
+    if (!found)
+	*ptr = line_end;
+
     return found;
 }