diff src/search.c @ 685:d7e33248b9c8 v7.0206

updated for version 7.0206
author vimboss
date Fri, 24 Feb 2006 23:53:04 +0000
parents 9364d114ed8d
children a28f83d37113
line wrap: on
line diff
--- a/src/search.c
+++ b/src/search.c
@@ -602,7 +602,11 @@ searchit(win, buf, pos, dir, pat, count,
 # ifdef FEAT_EVAL
 		    submatch = first_submatch(&regmatch);
 # endif
-		    ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE);
+		    /* Line me be past end of buffer for "\n\zs". */
+		    if (lnum + matchpos.lnum > buf->b_ml.ml_line_count)
+			ptr = (char_u *)"";
+		    else
+			ptr = ml_get_buf(buf, lnum + matchpos.lnum, FALSE);
 
 		    /*
 		     * Forward search in the first line: match should be after
@@ -886,6 +890,15 @@ searchit(win, buf, pos, dir, pat, count,
 	return FAIL;
     }
 
+    /* A pattern like "\n\zs" may go past the last line. */
+    if (pos->lnum > buf->b_ml.ml_line_count)
+    {
+	pos->lnum = buf->b_ml.ml_line_count;
+	pos->col = STRLEN(ml_get_buf(buf, pos->lnum, FALSE));
+	if (pos->col > 0)
+	    --pos->col;
+    }
+
     return submatch + 1;
 }