To: vim_dev@googlegroups.com Subject: Patch 7.4.1261 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1261 Problem: Pending channel messages are garbage collected. Leaking memory in ch_sendexpr(). Leaking memory for a decoded JSON string. Solution: Mark the message list as used. Free the encoded JSON. Don't save the JSON string. Files: src/eval.c, src/channel.c, src/json.c, src/proto/channel.pro *** ../vim-7.4.1260/src/eval.c 2016-02-02 20:46:29.711412047 +0100 --- src/eval.c 2016-02-04 22:40:45.289175845 +0100 *************** *** 6855,6860 **** --- 6855,6864 ---- abort = abort || set_ref_in_python3(copyID); #endif + #ifdef FEAT_CHANNEL + abort = abort || set_ref_in_channel(copyID); + #endif + if (!abort) { /* *************** *** 9842,9847 **** --- 9846,9852 ---- return; ch_idx = send_common(argvars, text, "sendexpr"); + vim_free(text); if (ch_idx >= 0) { if (channel_read_json_block(ch_idx, id, &listtv) == OK) *** ../vim-7.4.1260/src/channel.c 2016-02-04 22:09:44.692012667 +0100 --- src/channel.c 2016-02-04 22:37:22.011218253 +0100 *************** *** 1315,1318 **** --- 1315,1343 ---- return ret; } + int + set_ref_in_channel(int copyID) + { + int i; + int abort = FALSE; + + for (i = 0; i < channel_count; ++i) + { + jsonq_T *head = &channels[i].ch_json_head; + jsonq_T *item = head->next; + + while (item != head) + { + list_T *l = item->value->vval.v_list; + + if (l->lv_copyID != copyID) + { + l->lv_copyID = copyID; + abort = abort || set_ref_in_list(l, copyID, NULL); + } + item = item->next; + } + } + return abort; + } #endif /* FEAT_CHANNEL */ *** ../vim-7.4.1260/src/json.c 2016-02-02 19:43:53.042456259 +0100 --- src/json.c 2016-02-04 22:43:55.335218936 +0100 *************** *** 533,542 **** if (res != NULL) { res->v_type = VAR_STRING; ! if (ga.ga_data == NULL) ! res->vval.v_string = NULL; ! else ! res->vval.v_string = vim_strsave(ga.ga_data); } return OK; } --- 533,539 ---- if (res != NULL) { res->v_type = VAR_STRING; ! res->vval.v_string = ga.ga_data; } return OK; } *** ../vim-7.4.1260/src/proto/channel.pro 2016-02-02 23:22:38.101181704 +0100 --- src/proto/channel.pro 2016-02-04 22:36:55.923476301 +0100 *************** *** 22,25 **** --- 22,26 ---- int channel_select_setup(int maxfd_in, void *rfds_in); int channel_select_check(int ret_in, void *rfds_in); int channel_parse_messages(void); + int set_ref_in_channel(int copyID); /* vim: set ft=c : */ *** ../vim-7.4.1260/src/version.c 2016-02-04 22:09:44.692012667 +0100 --- src/version.c 2016-02-04 22:32:10.766231369 +0100 *************** *** 744,745 **** --- 744,747 ---- { /* Add new patch number below this line */ + /**/ + 1261, /**/ -- hundred-and-one symptoms of being an internet addict: 141. You'd rather go to http://www.weather.com/ than look out your window. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///