mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
lottie: Prevent memory leak when file is invalid
When json file is invalid in the parser, the LottieComposition object is not released and the parse() returns false. To prevent memory leaks, free the memory before returning false. related issue : https://github.com/thorvg/thorvg/issues/2070
This commit is contained in:
parent
6120729554
commit
dd2e7b9b4e
2 changed files with 7 additions and 4 deletions
|
@ -207,7 +207,7 @@ float LottieLayer::remap(float frameNo)
|
|||
|
||||
LottieComposition::~LottieComposition()
|
||||
{
|
||||
if (!initiated) delete(root->scene);
|
||||
if (!initiated && root) delete(root->scene);
|
||||
|
||||
delete(root);
|
||||
free(version);
|
||||
|
|
|
@ -1316,7 +1316,10 @@ bool LottieParser::parse()
|
|||
else skip(key);
|
||||
}
|
||||
|
||||
if (Invalid() || !comp->root) return false;
|
||||
if (Invalid() || !comp->root) {
|
||||
delete(comp);
|
||||
return false;
|
||||
}
|
||||
|
||||
comp->root->inFrame = comp->startFrame;
|
||||
comp->root->outFrame = comp->endFrame;
|
||||
|
|
Loading…
Add table
Reference in a new issue