Better algorithm validation.

This commit is contained in:
XMRig 2018-04-25 22:03:26 +07:00
parent a9cc5c5258
commit 230962230f
3 changed files with 29 additions and 2 deletions

View file

@ -164,7 +164,18 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a
}
# endif
return func_table[40 * algorithm + 10 * variant + av - 1];
const size_t index = 40 * algorithm + 10 * variant + av - 1;
# ifndef NDEBUG
cn_hash_fun func = func_table[index];
assert(index < sizeof(func_table) / sizeof(func_table[0]));
assert(func != nullptr);
return func;
# else
return func_table[index];
# endif
}