Return error if &div or &mod by 0.

This commit is contained in:
Renaud 2015-03-17 09:04:22 +08:00
parent f97746a87b
commit d01649bf3a
1 changed files with 4 additions and 2 deletions

6
eval.c
View File

@ -401,10 +401,12 @@ static char *gtfun( char *fname) {
retstr = i_to_a( atoi( arg1) * atoi( argx)) ;
break ;
case UFDIV:
retstr = i_to_a( atoi( arg1) / atoi( argx)) ;
sz = atoi( argx) ;
retstr = (sz == 0) ? errorm : i_to_a( atoi( arg1) / sz) ;
break ;
case UFMOD:
retstr = i_to_a( atoi( arg1) % atoi( argx)) ;
sz = atoi( argx) ;
retstr = (sz == 0) ? errorm : i_to_a( atoi( arg1) % sz) ;
break ;
case UFNEG:
retstr = i_to_a( -atoi( argx)) ;