mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
lottie: Fix crash when an invalid gradient is provided
When lottie is broken and provides invalid gradient, the program crashes in segmentation fault. At that time, in the `populate` function, `ColorStop& color` doesn't have `input` but tries to use it. Added checking nullptr logic. The function `populate` will not proceed and return 0 in that case. related issue: #2072
This commit is contained in:
parent
04b5525db4
commit
c8ddc316db
1 changed files with 3 additions and 1 deletions
|
@ -381,6 +381,9 @@ struct LottieGradient : LottieObject
|
|||
{
|
||||
uint32_t populate(ColorStop& color)
|
||||
{
|
||||
colorStops.populated = true;
|
||||
if (!color.input) 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
|
||||
|
@ -455,7 +458,6 @@ struct LottieGradient : LottieObject
|
|||
color.input->reset();
|
||||
delete(color.input);
|
||||
|
||||
colorStops.populated = true;
|
||||
return output.count;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue