mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +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
25645e087a
commit
c4da341f4b
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);
|
||||
|
@ -233,4 +233,4 @@ LottieComposition::~LottieComposition()
|
|||
for (auto s = slots.begin(); s < slots.end(); ++s) {
|
||||
delete(*s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -1324,4 +1327,4 @@ bool LottieParser::parse()
|
|||
postProcess(glyphes);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue