fix divide by zero in random

This commit is contained in:
Neale Pickett 2013-07-26 14:12:04 -06:00
parent 60e48c2b90
commit 575c8da393
1 changed files with 4 additions and 0 deletions

View File

@ -173,6 +173,10 @@ forf_proc_random(struct forf_env *env)
{
long max = forf_pop_num(env);
if (max < 1) {
forf_push_num(env, 0);
}
forf_push_num(env, rand() % max);
}