comparison src/vim9compile.c @ 23669:cf2904dd9691 v8.2.2376

patch 8.2.2376: Vim9: crash when dividing by zero in compiled code Commit: https://github.com/vim/vim/commit/e64f83cc6aba05baa61ba4a4cb8d4447b8091e5b Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jan 19 22:16:41 2021 +0100 patch 8.2.2376: Vim9: crash when dividing by zero in compiled code Problem: Vim9: crash when dividing by zero in compiled code using constants. Solution: Call num_divide() and num_modulus(). (closes #7704)
author Bram Moolenaar <Bram@vim.org>
date Tue, 19 Jan 2021 22:30:08 +0100
parents c761fcb89dfe
children e8c379b20765
comparison
equal deleted inserted replaced
23668:4e893aa1380c 23669:cf2904dd9691
4298 // both are numbers: compute the result 4298 // both are numbers: compute the result
4299 switch (*op) 4299 switch (*op)
4300 { 4300 {
4301 case '*': res = tv1->vval.v_number * tv2->vval.v_number; 4301 case '*': res = tv1->vval.v_number * tv2->vval.v_number;
4302 break; 4302 break;
4303 case '/': res = tv1->vval.v_number / tv2->vval.v_number; 4303 case '/': res = num_divide(tv1->vval.v_number,
4304 tv2->vval.v_number);
4304 break; 4305 break;
4305 case '%': res = tv1->vval.v_number % tv2->vval.v_number; 4306 case '%': res = num_modulus(tv1->vval.v_number,
4307 tv2->vval.v_number);
4306 break; 4308 break;
4307 } 4309 }
4308 tv1->vval.v_number = res; 4310 tv1->vval.v_number = res;
4309 --ppconst->pp_used; 4311 --ppconst->pp_used;
4310 } 4312 }