mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avcodec/ass: Fix leaks upon ff_ass_add_rect() error
Do this by actually incrementing the counter for the number of rects at the right time. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
cee04cbfe1
commit
2adbb0c2af
@ -118,22 +118,22 @@ int ff_ass_add_rect(AVSubtitle *sub, const char *dialog,
|
||||
int readorder, int layer, const char *style,
|
||||
const char *speaker)
|
||||
{
|
||||
AVSubtitleRect **rects, *rect;
|
||||
char *ass_str;
|
||||
AVSubtitleRect **rects;
|
||||
|
||||
rects = av_realloc_array(sub->rects, sub->num_rects+1, sizeof(*sub->rects));
|
||||
if (!rects)
|
||||
return AVERROR(ENOMEM);
|
||||
sub->rects = rects;
|
||||
rects[sub->num_rects] = av_mallocz(sizeof(*rects[0]));
|
||||
if (!rects[sub->num_rects])
|
||||
rect = av_mallocz(sizeof(*rect));
|
||||
if (!rect)
|
||||
return AVERROR(ENOMEM);
|
||||
rects[sub->num_rects]->type = SUBTITLE_ASS;
|
||||
rects[sub->num_rects++] = rect;
|
||||
rect->type = SUBTITLE_ASS;
|
||||
ass_str = ff_ass_get_dialog(readorder, layer, style, speaker, dialog);
|
||||
if (!ass_str)
|
||||
return AVERROR(ENOMEM);
|
||||
rects[sub->num_rects]->ass = ass_str;
|
||||
sub->num_rects++;
|
||||
rect->ass = ass_str;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user