Commit 876a83024db3eef893cdc14dcf1377fd867331cf

Con Kolivas 2013-11-02T11:20:26

Sanity check for absurd target setting and divide by zero.

1
2
3
4
5
6
7
8
9
10
11
12
13
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;