Browse Source

cpu: Fail gracefully if unsupported mining algo gets into scanhash

Luke Dashjr 11 years ago
parent
commit
318cc0584b
1 changed files with 3 additions and 1 deletions
  1. 3 1
      driver-cpu.c

+ 3 - 1
driver-cpu.c

@@ -820,7 +820,7 @@ CPUSearch:
 
 
 	/* scan nonces for a proof-of-work hash */
 	/* scan nonces for a proof-of-work hash */
 	{
 	{
-		sha256_func func;
+		sha256_func func = NULL;
 		switch (work_mining_algorithm(work)->algo)
 		switch (work_mining_algorithm(work)->algo)
 		{
 		{
 #ifdef USE_SCRYPT
 #ifdef USE_SCRYPT
@@ -832,6 +832,8 @@ CPUSearch:
 				func = sha256_funcs[opt_algo];
 				func = sha256_funcs[opt_algo];
 				break;
 				break;
 		}
 		}
+		if (unlikely(!func))
+			applogr(0, LOG_ERR, "%"PRIpreprv": Unknown mining algorithm", thr->cgpu->proc_repr);
 		rc = (*func)(
 		rc = (*func)(
 			thr,
 			thr,
 			work->midstate,
 			work->midstate,