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:
16
src/typval.c
16
src/typval.c
@@ -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.
|
||||
|
Reference in New Issue
Block a user