mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-22 12:34:27 +00:00
Fix potential division by 0 if nfactor is not set
This commit is contained in:
parent
b4dd3aeb75
commit
72590bdcf2
@ -667,7 +667,7 @@ void set_algorithm(algorithm_t* algo, const char* newname_alias)
|
|||||||
const char* newname;
|
const char* newname;
|
||||||
//load previous algorithm nfactor in case nfactor was applied before algorithm... or default to 10
|
//load previous algorithm nfactor in case nfactor was applied before algorithm... or default to 10
|
||||||
uint8_t old_nfactor = ((algo->nfactor)?algo->nfactor:0);
|
uint8_t old_nfactor = ((algo->nfactor)?algo->nfactor:0);
|
||||||
uint8_t nfactor = 0;
|
uint8_t nfactor = 10;
|
||||||
|
|
||||||
if (!(newname = lookup_algorithm_alias(newname_alias, &nfactor)))
|
if (!(newname = lookup_algorithm_alias(newname_alias, &nfactor)))
|
||||||
newname = newname_alias;
|
newname = newname_alias;
|
||||||
@ -678,9 +678,7 @@ void set_algorithm(algorithm_t* algo, const char* newname_alias)
|
|||||||
if ((old_nfactor > 0) && (old_nfactor != nfactor))
|
if ((old_nfactor > 0) && (old_nfactor != nfactor))
|
||||||
nfactor = old_nfactor;
|
nfactor = old_nfactor;
|
||||||
|
|
||||||
// Doesn't matter for non-scrypt algorithms
|
set_algorithm_nfactor(algo, nfactor);
|
||||||
if (nfactor > 0)
|
|
||||||
set_algorithm_nfactor(algo, nfactor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_algorithm_nfactor(algorithm_t* algo, const uint8_t nfactor)
|
void set_algorithm_nfactor(algorithm_t* algo, const uint8_t nfactor)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user