From 575c8da393f1c2b17564979b3286bde411067fdb Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Fri, 26 Jul 2013 14:12:04 -0600 Subject: [PATCH] fix divide by zero in random --- forftanks.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/forftanks.c b/forftanks.c index 65205fc..24e62f9 100644 --- a/forftanks.c +++ b/forftanks.c @@ -172,6 +172,10 @@ void 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); }