}
else
{
- typval_T *tv;
+ typval_T *tv = NULL;
typval_T res_tv;
typval_T err_tv;
char_u *json = NULL;
ch_logs(channel, "Calling '%s'", (char *)arg);
if (func_call(arg, &argv[2], NULL, NULL, &res_tv) == OK)
tv = &res_tv;
- else
- tv = NULL;
}
if (argv[id_idx].v_type == VAR_NUMBER)
/* If evaluation failed or the result can't be encoded
* then return the string "ERROR". */
vim_free(json);
- free_tv(tv);
err_tv.v_type = VAR_STRING;
err_tv.vval.v_string = (char_u *)"ERROR";
- tv = &err_tv;
- json = json_encode_nr_expr(id, tv, options | JSON_NL);
+ json = json_encode_nr_expr(id, &err_tv, options | JSON_NL);
}
if (json != NULL)
{
--emsg_skip;
if (tv == &res_tv)
clear_tv(tv);
- else if (tv != &err_tv)
+ else
free_tv(tv);
}
}