vim-patch:9.0.1995: Invalid memory access with empty 'foldexpr' (#25530)

Problem:  Invalid memory access when 'foldexpr' returns empty string.
Solution: Check for NUL.

closes: vim/vim#13293

a991ce9c08
This commit is contained in:
zeertzjq
2023-10-07 06:32:06 +08:00
committed by GitHub
parent 5db076c7cc
commit 1ac588543d
2 changed files with 10 additions and 1 deletions

View File

@@ -1299,7 +1299,7 @@ int eval_foldexpr(win_T *wp, int *cp)
// If the result is a string, check if there is a non-digit before
// the number.
char *s = tv.vval.v_string;
if (!ascii_isdigit(*s) && *s != '-') {
if (*s != NUL && !ascii_isdigit(*s) && *s != '-') {
*cp = (uint8_t)(*s++);
}
retval = atol(s);