Merge pull request #6558 from jamessan/tv_as_string-fix

eval: save_tv_as_string: Correctly handle an empty string
This commit is contained in:
James McCoy
2018-01-25 14:09:36 -05:00
committed by GitHub
2 changed files with 5 additions and 1 deletions

View File

@@ -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;