mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-18 22:11:32 +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
75d08aec07
commit
6e2275116e
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