Mercurial > vim
comparison src/channel.c @ 7937:2e905dfc6999 v7.4.1264
commit https://github.com/vim/vim/commit/6076fe1986255d32b7a078a28bf9e7bea19d6f30
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Feb 5 22:49:56 2016 +0100
patch 7.4.1264
Problem: Crash when receiving an empty array.
Solution: Check for array with wrong number of arguments. (Damien)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 05 Feb 2016 23:00:05 +0100 |
parents | 3f2e0b62003d |
children | e72438a11172 |
comparison
equal
deleted
inserted
replaced
7936:a058fba2b5fd | 7937:2e905dfc6999 |
---|---|
686 /* reader.js_fill = channel_fill; */ | 686 /* reader.js_fill = channel_fill; */ |
687 reader.js_cookie = &ch_idx; | 687 reader.js_cookie = &ch_idx; |
688 ret = json_decode(&reader, &listtv); | 688 ret = json_decode(&reader, &listtv); |
689 if (ret == OK) | 689 if (ret == OK) |
690 { | 690 { |
691 if (listtv.v_type != VAR_LIST) | 691 /* Only accept the response when it is a list with at least two |
692 * items. */ | |
693 if (listtv.v_type != VAR_LIST || listtv.vval.v_list->lv_len < 2) | |
692 { | 694 { |
693 /* TODO: give error */ | 695 /* TODO: give error */ |
694 clear_tv(&listtv); | 696 clear_tv(&listtv); |
695 } | 697 } |
696 else | 698 else |
907 if (channel_get_json(idx, -1, &listtv) == FAIL) | 909 if (channel_get_json(idx, -1, &listtv) == FAIL) |
908 return FALSE; | 910 return FALSE; |
909 } | 911 } |
910 | 912 |
911 list = listtv->vval.v_list; | 913 list = listtv->vval.v_list; |
912 if (list->lv_len < 2) | |
913 { | |
914 /* TODO: give error */ | |
915 clear_tv(listtv); | |
916 return FALSE; | |
917 } | |
918 | |
919 argv[1] = list->lv_first->li_next->li_tv; | 914 argv[1] = list->lv_first->li_next->li_tv; |
920 typetv = &list->lv_first->li_tv; | 915 typetv = &list->lv_first->li_tv; |
921 if (typetv->v_type == VAR_STRING) | 916 if (typetv->v_type == VAR_STRING) |
922 { | 917 { |
923 typval_T *arg3 = NULL; | 918 typval_T *arg3 = NULL; |