diff src/eval.c @ 33488:0081ca43bee9 v9.0.1995

patch 9.0.1995: Invalid memory access with empty 'foldexpr' Commit: https://github.com/vim/vim/commit/a991ce9c083bb8c02b1b1ec34ed35728197050f3 Author: zeertzjq <zeertzjq@outlook.com> Date: Fri Oct 6 19:16:36 2023 +0200 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>
author Christian Brabandt <cb@256bit.org>
date Fri, 06 Oct 2023 19:30:07 +0200
parents 3de472480e91
children bff8ac203a22
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -968,7 +968,7 @@ eval_foldexpr(win_T *wp, int *cp)
 	    // 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);
 	}