fix(eval): checking for a non-empty string is too strict (#15987)

Cherry-pick check_for_nonempty_string() from patch vim-8.2.2133 and
apply it on the bases of https://github.com/neovim/neovim/pull/13489

2a9d5d386b
This commit is contained in:
Fabian
2021-10-29 04:13:40 +02:00
committed by GitHub
parent bb79e05f81
commit 1dbbaf89bf
6 changed files with 29 additions and 10 deletions

View File

@@ -2201,7 +2201,7 @@ static void f_win_execute(typval_T *argvars, typval_T *rettv, FunPtr fptr)
/// "exepath()" function
static void f_exepath(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
if (tv_check_for_string(&argvars[0]) == FAIL) {
if (tv_check_for_nonempty_string(&argvars[0]) == FAIL) {
return;
}
@@ -2661,9 +2661,9 @@ static void f_fnamemodify(typval_T *argvars, typval_T *rettv, FunPtr fptr)
char buf[NUMBUFLEN];
const char *fname = tv_get_string_chk(&argvars[0]);
const char *const mods = tv_get_string_buf_chk(&argvars[1], buf);
if (fname == NULL || mods == NULL) {
if (fname == NULL) {
fname = NULL;
} else {
} else if (mods != NULL && *mods != NUL) {
len = strlen(fname);
size_t usedlen = 0;
if (*mods != NUL) {