Sanity check for absurd target setting and divide by zero.
diff --git a/cgminer.c b/cgminer.c
index 2ea0d1f..76bfcc2 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -3114,6 +3114,8 @@ static void calc_diff(struct work *work, double known)
if (opt_scrypt)
d64 *= (double)65536;
dcut64 = le256todouble(work->target);
+ if (unlikely(!dcut64))
+ dcut64 = 1;
work->work_difficulty = d64 / dcut64;
}
difficulty = work->work_difficulty;