To: vim_dev@googlegroups.com Subject: Patch 8.2.2376 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2376 Problem: Vim9: crash when dividing by zero in compiled code using constants. Solution: Call num_divide() and num_modulus(). (closes #7704) Files: src/vim9compile.c, src/testdir/test_vim9_expr.vim *** ../vim-8.2.2375/src/vim9compile.c 2021-01-17 21:51:18.947791147 +0100 --- src/vim9compile.c 2021-01-19 22:12:39.781096592 +0100 *************** *** 4300,4308 **** { case '*': res = tv1->vval.v_number * tv2->vval.v_number; break; ! case '/': res = tv1->vval.v_number / tv2->vval.v_number; break; ! case '%': res = tv1->vval.v_number % tv2->vval.v_number; break; } tv1->vval.v_number = res; --- 4300,4310 ---- { case '*': res = tv1->vval.v_number * tv2->vval.v_number; break; ! case '/': res = num_divide(tv1->vval.v_number, ! tv2->vval.v_number); break; ! case '%': res = num_modulus(tv1->vval.v_number, ! tv2->vval.v_number); break; } tv1->vval.v_number = res; *** ../vim-8.2.2375/src/testdir/test_vim9_expr.vim 2021-01-14 20:35:46.254002151 +0100 --- src/testdir/test_vim9_expr.vim 2021-01-19 22:15:29.776685984 +0100 *************** *** 1376,1381 **** --- 1376,1382 ---- assert_equal(1, g:anint / 6) assert_equal(2, g:anint / g:thefour) + assert_true(1 / 0 > 99999) assert_equal(5, 11 % 6) assert_equal(4, g:anint % 6) *************** *** 1383,1388 **** --- 1384,1390 ---- g:anint) assert_equal(2, g:anint % g:thefour) + assert_equal(0, 1 % 0) assert_equal(4, 6 * 4 / 6) *** ../vim-8.2.2375/src/version.c 2021-01-19 17:22:50.648402996 +0100 --- src/version.c 2021-01-19 22:14:01.476900350 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2376, /**/ -- hundred-and-one symptoms of being an internet addict: 187. You promise yourself that you'll only stay online for another 15 minutes...at least once every hour. /// 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 ///