Skip to content

Commit 66624ff

Browse files
committed
patch 7.4.1255
Problem: Crash for channel "eval" command without third argument. Solution: Check for missing argument.
1 parent 3b05b13 commit 66624ff

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

src/channel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ channel_exe_cmd(int idx, char_u *cmd, typval_T *arg2, typval_T *arg3)
694694
{
695695
int is_eval = cmd[1] == 'v';
696696

697-
if (is_eval && arg3->v_type != VAR_NUMBER)
697+
if (is_eval && (arg3 == NULL || arg3->v_type != VAR_NUMBER))
698698
{
699699
if (p_verbose > 2)
700700
EMSG("E904: third argument for eval must be a number");
@@ -774,7 +774,7 @@ may_invoke_callback(int idx)
774774
typval_T *arg3 = NULL;
775775
char_u *cmd = typetv->vval.v_string;
776776

777-
/* ["cmd", arg] */
777+
/* ["cmd", arg] or ["cmd", arg, arg] */
778778
if (list->lv_len == 3)
779779
arg3 = &list->lv_last->li_tv;
780780
channel_exe_cmd(idx, cmd, &argv[1], arg3);

src/testdir/test_channel.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def handle(self):
6868
# simply send back a string
6969
response = "got it"
7070
elif decoded[1] == 'make change':
71-
# Send two ex commands at the same time, before replying to
72-
# the request.
71+
# Send two ex commands at the same time, before
72+
# replying to the request.
7373
cmd = '["ex","call append(\\"$\\",\\"added1\\")"]'
7474
cmd += '["ex","call append(\\"$\\",\\"added2\\")"]'
7575
print("sending: {}".format(cmd))
@@ -87,6 +87,12 @@ def handle(self):
8787
print("sending: {}".format(cmd))
8888
self.request.sendall(cmd.encode('utf-8'))
8989
response = "ok"
90+
elif decoded[1] == 'eval-bad':
91+
# Send an eval request missing the third argument.
92+
cmd = '["eval","xxx"]'
93+
print("sending: {}".format(cmd))
94+
self.request.sendall(cmd.encode('utf-8'))
95+
response = "ok"
9096
elif decoded[1] == 'eval-result':
9197
# Send back the last received eval result.
9298
response = last_eval

src/testdir/test_channel.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ func Test_communicate()
9090
call assert_equal('ok', ch_sendexpr(handle, 'eval-fails'))
9191
call assert_equal([-2, 'ERROR'], ch_sendexpr(handle, 'eval-result'))
9292

93+
" Send a bad eval request. There will be no response.
94+
call assert_equal('ok', ch_sendexpr(handle, 'eval-bad'))
95+
call assert_equal([-2, 'ERROR'], ch_sendexpr(handle, 'eval-result'))
96+
9397
" make the server quit, can't check if this works, should not hang.
9498
call ch_sendexpr(handle, '!quit!', 0)
9599

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,8 @@ static char *(features[]) =
742742

743743
static int included_patches[] =
744744
{ /* Add new patch number below this line */
745+
/**/
746+
1255,
745747
/**/
746748
1254,
747749
/**/

0 commit comments

Comments
 (0)