patch 9.0.1995: Invalid memory access with empty 'foldexpr'
Problem: Invalid memory access when 'foldexpr' returns empty string.
Solution: Check for NUL.
closes: #13293
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
diff --git a/src/eval.c b/src/eval.c
index 19ab015..a9f7112 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -968,7 +968,7 @@
// If the result is a string, check if there is a non-digit before
// the number.
s = tv.vval.v_string;
- if (!VIM_ISDIGIT(*s) && *s != '-')
+ if (*s != NUL && !VIM_ISDIGIT(*s) && *s != '-')
*cp = *s++;
retval = atol((char *)s);
}
diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim
index 398a0c2..cb29d43 100644
--- a/src/testdir/test_fold.vim
+++ b/src/testdir/test_fold.vim
Binary files differ
diff --git a/src/version.c b/src/version.c
index 057cae5..ce13dcc 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1995,
+/**/
1994,
/**/
1993,