mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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:
parent
5db076c7cc
commit
1ac588543d
@ -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
|
// If the result is a string, check if there is a non-digit before
|
||||||
// the number.
|
// the number.
|
||||||
char *s = tv.vval.v_string;
|
char *s = tv.vval.v_string;
|
||||||
if (!ascii_isdigit(*s) && *s != '-') {
|
if (*s != NUL && !ascii_isdigit(*s) && *s != '-') {
|
||||||
*cp = (uint8_t)(*s++);
|
*cp = (uint8_t)(*s++);
|
||||||
}
|
}
|
||||||
retval = atol(s);
|
retval = atol(s);
|
||||||
|
@ -1569,4 +1569,13 @@ func Test_foldcolumn_linebreak_control_char()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" This used to cause invalid memory access
|
||||||
|
func Test_foldexpr_return_empty_string()
|
||||||
|
new
|
||||||
|
setlocal foldexpr='' foldmethod=expr
|
||||||
|
redraw
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Loading…
Reference in New Issue
Block a user