aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index f50a215559..67a68f70d5 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -15278,7 +15278,7 @@ static void f_winrestview(typval_T *argvars, typval_T *rettv)
win_new_width(curwin, curwin->w_width);
changed_window_setting();
- if (curwin->w_topline == 0)
+ if (curwin->w_topline <= 0)
curwin->w_topline = 1;
if (curwin->w_topline > curbuf->b_ml.ml_line_count)
curwin->w_topline = curbuf->b_ml.ml_line_count;
@@ -19665,6 +19665,7 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags)
regmatch_T regmatch;
int do_all;
char_u *tail;
+ char_u *end;
garray_T ga;
char_u *save_cpo;
char_u *zero_width = NULL;
@@ -19681,6 +19682,7 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags)
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
if (regmatch.regprog != NULL) {
tail = str;
+ end = str + STRLEN(str);
while (vim_regexec_nl(&regmatch, str, (colnr_T)(tail - str))) {
/* Skip empty match except for first match. */
if (regmatch.startp[0] == regmatch.endp[0]) {
@@ -19703,7 +19705,7 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags)
* - The text after the match.
*/
sublen = vim_regsub(&regmatch, sub, tail, FALSE, TRUE, FALSE);
- ga_grow(&ga, (int)(STRLEN(tail) + sublen -
+ ga_grow(&ga, (int)((end - tail) + sublen -
(regmatch.endp[0] - regmatch.startp[0])));
/* copy the text up to where the match is */