Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e4f0dba authored by James O'Leary's avatar James O'Leary Committed by Automerger Merge Worker
Browse files

Merge "Fix crash when number of pixels < max colors" into sc-dev am: c4748fda

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13745605

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Iac0cda102a74866ce802695787c5bd25193a03b9
parents 410da4ce c4748fda
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.internal.graphics.palette;


import java.util.ArrayList;
import java.util.List;

@@ -120,7 +119,11 @@ public class WuQuantizer implements Quantizer {
            }
        }

        for (k = 0; k < mMaxColors; ++k) {
        // If extraction is run on a set of pixels whose count is less than the
        // number of max colors, then colors.length < max colors, and accesses
        // to colors[index] inside the for loop throw an ArrayOutOfBoundsException.
        int numColorsToCreate = (int) Math.min(mMaxColors, colors.length);
        for (k = 0; k < numColorsToCreate; ++k) {
            weight = getVolume(cube[k], mWt);
            if (weight > 0) {
                red = (int) (getVolume(cube[k], mMr) / weight);