1
0
forked from aniani/vim

patch 8.2.2117: some functions use any value as a string

Problem:    Some functions use any value as a string.
Solution:   Check that the value is a non-empty string.
This commit is contained in:
Bram Moolenaar
2020-12-09 12:41:50 +01:00
parent 2c78a772fd
commit 7bb4e74c38
7 changed files with 113 additions and 13 deletions

View File

@@ -340,6 +340,22 @@ tv_get_float(typval_T *varp)
}
#endif
/*
* Give an error and return FAIL unless "tv" is a non-empty string.
*/
int
check_for_string(typval_T *tv)
{
if (tv->v_type != VAR_STRING
|| tv->vval.v_string == NULL
|| *tv->vval.v_string == NUL)
{
emsg(_(e_stringreq));
return FAIL;
}
return OK;
}
/*
* Get the string value of a variable.
* If it is a Number variable, the number is converted into a string.