To: vim_dev@googlegroups.com Subject: Patch 8.2.2422 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2422 Problem: Crash when deleting with line number out of range. (Houyunsong) Solution: Avoid using a negative line number. Files: src/normal.c, src/testdir/test_ex_mode.vim *** ../vim-8.2.2421/src/normal.c 2021-01-21 17:03:04.475217089 +0100 --- src/normal.c 2021-01-28 17:23:19.966217892 +0100 *************** *** 630,636 **** } else ca.count0 = ca.count0 * 10 + (c - '0'); ! if (ca.count0 < 0) // got too large! ca.count0 = 999999999L; #ifdef FEAT_EVAL // Set v:count here, when called from main() and not a stuffed --- 630,636 ---- } else ca.count0 = ca.count0 * 10 + (c - '0'); ! if (ca.count0 < 0) // overflow ca.count0 = 999999999L; #ifdef FEAT_EVAL // Set v:count here, when called from main() and not a stuffed *************** *** 701,706 **** --- 701,708 ---- ca.count0 *= ca.opcount; else ca.count0 = ca.opcount; + if (ca.count0 < 0) // overflow + ca.count0 = 999999999L; } /* *************** *** 4775,4780 **** --- 4777,4784 ---- else curwin->w_cursor.lnum = (curbuf->b_ml.ml_line_count * cap->count0 + 99L) / 100L; + if (curwin->w_cursor.lnum < 1) + curwin->w_cursor.lnum = 1; if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; beginline(BL_SOL | BL_FIX); *** ../vim-8.2.2421/src/testdir/test_ex_mode.vim 2020-11-23 18:14:51.272875917 +0100 --- src/testdir/test_ex_mode.vim 2021-01-28 17:24:27.761919848 +0100 *************** *** 206,209 **** --- 206,225 ---- call delete('Xexmodescript') endfunc + func Test_ex_mode_count_overflow() + " this used to cause a crash + let lines =<< trim END + call feedkeys("\Q\") + v9|9silent! vi|333333233333y32333333%O + call writefile(['done'], 'Xdidexmode') + qall! + END + call writefile(lines, 'Xexmodescript') + call assert_equal(1, RunVim([], [], '-e -s -S Xexmodescript -c qa')) + call assert_equal(['done'], readfile('Xdidexmode')) + + call delete('Xdidexmode') + call delete('Xexmodescript') + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.2421/src/version.c 2021-01-28 14:24:51.181688004 +0100 --- src/version.c 2021-01-28 17:23:43.858112670 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2422, /**/ -- Place mark here ->[ ]<- if you want a dirty monitor. /// 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 ///