To: vim_dev@googlegroups.com Subject: Patch 8.2.1848 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1848 Problem: Crash when passing a NULL string or list to popup_settext(). Solution: Check for NULL pointers. (closes #7132) Files: src/popupwin.c, src/testdir/test_popupwin.vim *** ../vim-8.2.1847/src/popupwin.c 2020-09-27 21:16:41.760046900 +0200 --- src/popupwin.c 2020-10-15 19:09:26.239855116 +0200 *************** *** 1595,1608 **** // Add text to the buffer. if (text.v_type == VAR_STRING) { // just a string ! ml_append_buf(buf, 0, text.vval.v_string, (colnr_T)0, TRUE); } else { list_T *l = text.vval.v_list; ! if (l->lv_len > 0) { if (l->lv_first->li_tv.v_type == VAR_STRING) // list of strings --- 1595,1610 ---- // Add text to the buffer. if (text.v_type == VAR_STRING) { + char_u *s = text.vval.v_string; + // just a string ! ml_append_buf(buf, 0, s == NULL ? (char_u *)"" : s, (colnr_T)0, TRUE); } else { list_T *l = text.vval.v_list; ! if (l != NULL && l->lv_len > 0) { if (l->lv_first->li_tv.v_type == VAR_STRING) // list of strings *** ../vim-8.2.1847/src/testdir/test_popupwin.vim 2020-10-06 20:46:43.767871541 +0200 --- src/testdir/test_popupwin.vim 2020-10-15 19:09:13.523891438 +0200 *************** *** 2363,2368 **** --- 2363,2378 ---- call popup_close(id) endfunc + func Test_popup_settext_null() + let id = popup_create('', #{ tabpage: 0 }) + call popup_settext(id, test_null_list()) + call popup_close(id) + + let id = popup_create('', #{ tabpage: 0 }) + call popup_settext(id, test_null_string()) + call popup_close(id) + endfunc + func Test_popup_hidden() new *** ../vim-8.2.1847/src/version.c 2020-10-15 13:57:52.098225999 +0200 --- src/version.c 2020-10-15 19:03:28.332875888 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 1848, /**/ -- From "know your smileys": :-O>-o Smiley American tourist (note big mouth and camera) /// 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 ///