patch 9.0.1145: invalid memory access with recursive substitute expression
Problem: Invalid memory access with recursive substitute expression.
Solution: Check the return value of vim_regsub().
diff --git a/src/eval.c b/src/eval.c
index 2fbd867..9ca8050 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -7312,6 +7312,11 @@
* - The text after the match.
*/
sublen = vim_regsub(®match, sub, expr, tail, 0, REGSUB_MAGIC);
+ if (sublen <= 0)
+ {
+ ga_clear(&ga);
+ break;
+ }
if (ga_grow(&ga, (int)((end - tail) + sublen -
(regmatch.endp[0] - regmatch.startp[0]))) == FAIL)
{