mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 01:08:20 +00:00
eval: save_tv_as_string: Correctly handle an empty string
When tv_get_string_chk returns a non-NULL value, we have a valid string. Propagating an error state (*len = -1, NULL return) for an empty string is invalid. Closes #6554
This commit is contained in:
@@ -17504,7 +17504,8 @@ static char *save_tv_as_string(typval_T *tv, ptrdiff_t *const len, bool endnl)
|
||||
// print an error.
|
||||
if (tv->v_type != VAR_LIST && tv->v_type != VAR_NUMBER) {
|
||||
const char *ret = tv_get_string_chk(tv);
|
||||
if (ret && (*len = strlen(ret))) {
|
||||
if (ret) {
|
||||
*len = strlen(ret);
|
||||
return xmemdupz(ret, (size_t)(*len));
|
||||
} else {
|
||||
*len = -1;
|
||||
|
Reference in New Issue
Block a user