diff options
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 8d517fa4d2..8d38df8421 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -8375,6 +8375,10 @@ char *do_string_sub(char *str, char *pat, char *sub, typval_T *expr, const char // - The substituted text. // - The text after the match. sublen = vim_regsub(®match, sub, expr, tail, 0, REGSUB_MAGIC); + if (sublen <= 0) { + ga_clear(&ga); + break; + } ga_grow(&ga, (int)((end - tail) + sublen - (regmatch.endp[0] - regmatch.startp[0]))); |