To: vim_dev@googlegroups.com Subject: Patch 9.0.0020 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0020 Problem: With some completion reading past end of string. Solution: Check the length of the string. Files: src/insexpand.c, src/testdir/test_ins_complete.vim *** ../vim-9.0.0019/src/insexpand.c 2022-06-16 11:37:00.000000000 +0100 --- src/insexpand.c 2022-07-01 19:56:29.910114440 +0100 *************** *** 2209,2219 **** // but only do this, if the Popup is still visible if (c == Ctrl_E) { ins_compl_delete(); if (compl_leader != NULL) ! ins_bytes(compl_leader + get_compl_len()); else if (compl_first_match != NULL) ! ins_bytes(compl_orig_text + get_compl_len()); retval = TRUE; } --- 2209,2229 ---- // but only do this, if the Popup is still visible if (c == Ctrl_E) { + char_u *p = NULL; + ins_compl_delete(); if (compl_leader != NULL) ! p = compl_leader; else if (compl_first_match != NULL) ! p = compl_orig_text; ! if (p != NULL) ! { ! int compl_len = get_compl_len(); ! int len = (int)STRLEN(p); ! ! if (len > compl_len) ! ins_bytes_len(p + compl_len, len - compl_len); ! } retval = TRUE; } *** ../vim-9.0.0019/src/testdir/test_ins_complete.vim 2022-05-27 17:18:23.000000000 +0100 --- src/testdir/test_ins_complete.vim 2022-07-01 19:53:46.278493501 +0100 *************** *** 2184,2187 **** --- 2184,2195 ---- delfunction! FooBarComplete endfunc + func Test_complete_overrun() + " this was going past the end of the copied text + new + sil norm si”0s0  + bwipe! + endfunc + + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-9.0.0019/src/version.c 2022-07-01 19:11:20.385531915 +0100 --- src/version.c 2022-07-01 19:52:44.686633321 +0100 *************** *** 737,738 **** --- 737,740 ---- { /* Add new patch number below this line */ + /**/ + 20, /**/ -- hundred-and-one symptoms of being an internet addict: 36. You miss more than five meals a week downloading the latest games from Apogee. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///