lottie: Fix heap-buffer-overflow in gradient populate

This commit is contained in:
Jinny You 2024-04-03 13:09:05 +09:00 committed by Hermet Park
parent 349fd266b9
commit f54f22ae78

View file

@ -383,12 +383,16 @@ struct LottieGradient : LottieObject
uint32_t populate(ColorStop& color)
{
colorStops.populated = true;
if (!color.input) return 0;
if (!color.input || color.input->count % 4 != 0) {
TVGERR("LOTTIE", "The given colorstop value is not correct!");
return 0;
}
uint32_t alphaCnt = (color.input->count - (colorStops.count * 4)) / 2;
Array<Fill::ColorStop> output(colorStops.count + alphaCnt);
uint32_t cidx = 0; //color count
uint32_t clast = colorStops.count * 4;
if (clast > color.input->count) clast = color.input->count;
uint32_t aidx = clast; //alpha count
Fill::ColorStop cs;