1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-11-12 23:56:51 -05:00

Fix CID 39910: &rnd 0 return a pseudo-random number instead of triggering a zero divide crash.

This commit is contained in:
Renaud 2015-03-18 12:27:55 +08:00
parent b1cc7bfe3a
commit eb7217f8ec

8
eval.c
View File

@ -546,7 +546,13 @@ static char *gtfun( char *fname) {
retstr = result ;
break ;
case UFRND:
retstr = i_to_a( (ernd() % abs( atoi( argx))) + 1) ;
sz = abs( atoi( argx)) ;
if( sz == 0)
sz = ernd() ;
else
sz = ernd() % sz + 1 ;
retstr = i_to_a( sz) ;
break ;
case UFABS:
retstr = i_to_a( abs( atoi( argx))) ;