mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 7.4.1278
Problem: When jsonencode() fails it still returns something. Solution: Return an empty string on failure.
This commit is contained in:
@@ -853,24 +853,31 @@ channel_exe_cmd(int idx, char_u *cmd, typval_T *arg2, typval_T *arg3)
|
||||
{
|
||||
typval_T *tv;
|
||||
typval_T err_tv;
|
||||
char_u *json;
|
||||
char_u *json = NULL;
|
||||
|
||||
/* Don't pollute the display with errors. */
|
||||
++emsg_skip;
|
||||
tv = eval_expr(arg, NULL);
|
||||
--emsg_skip;
|
||||
if (is_eval)
|
||||
{
|
||||
if (tv == NULL)
|
||||
if (tv != NULL)
|
||||
json = json_encode_nr_expr(arg3->vval.v_number, tv);
|
||||
if (tv == NULL || (json != NULL && *json == NUL))
|
||||
{
|
||||
/* If evaluation failed or the result can't be encoded
|
||||
* then return the string "ERROR". */
|
||||
err_tv.v_type = VAR_STRING;
|
||||
err_tv.vval.v_string = (char_u *)"ERROR";
|
||||
tv = &err_tv;
|
||||
json = json_encode_nr_expr(arg3->vval.v_number, tv);
|
||||
}
|
||||
if (json != NULL)
|
||||
{
|
||||
channel_send(idx, json, "eval");
|
||||
vim_free(json);
|
||||
}
|
||||
json = json_encode_nr_expr(arg3->vval.v_number, tv);
|
||||
channel_send(idx, json, "eval");
|
||||
vim_free(json);
|
||||
}
|
||||
--emsg_skip;
|
||||
if (tv != &err_tv)
|
||||
free_tv(tv);
|
||||
}
|
||||
|
Reference in New Issue
Block a user