Merge pull request #3196 from tkoeppe/avg_fix

[QuantOctree.c] Remove erroneous attempt to average over an empty range
This commit is contained in:
Hugo 2018-07-01 21:45:46 +03:00 committed by GitHub
commit 241ea6b283
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -259,6 +259,10 @@ subtract_color_buckets(ColorCube cube, ColorBucket buckets, long nBuckets) {
Pixel p;
for (i=0; i<nBuckets; i++) {
subtrahend = &buckets[i];
// If the subtrahend contains no buckets, there is nothing to subtract.
if (subtrahend->count == 0) continue;
avg_color_from_color_bucket(subtrahend, &p);
minuend = color_bucket_from_cube(cube, &p);
minuend->count -= subtrahend->count;