Assert no divison by 0, correct superblocks 0 sequences case (#2592)

This commit is contained in:
sen
2021-05-07 13:26:56 -04:00
committed by GitHub
parent b4637d152a
commit 9e94b7cac5
3 changed files with 27 additions and 7 deletions
+2
View File
@@ -85,6 +85,8 @@ static size_t ZSTD_entropyCost(unsigned const* count, unsigned const max, size_t
{
unsigned cost = 0;
unsigned s;
assert(total > 0);
for (s = 0; s <= max; ++s) {
unsigned norm = (unsigned)((256 * count[s]) / total);
if (count[s] != 0 && norm == 0)