mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +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,
|
int readorder, int layer, const char *style,
|
||||||
const char *speaker)
|
const char *speaker)
|
||||||
{
|
{
|
||||||
|
AVSubtitleRect **rects, *rect;
|
||||||
char *ass_str;
|
char *ass_str;
|
||||||
AVSubtitleRect **rects;
|
|
||||||
|
|
||||||
rects = av_realloc_array(sub->rects, sub->num_rects+1, sizeof(*sub->rects));
|
rects = av_realloc_array(sub->rects, sub->num_rects+1, sizeof(*sub->rects));
|
||||||
if (!rects)
|
if (!rects)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
sub->rects = rects;
|
sub->rects = rects;
|
||||||
rects[sub->num_rects] = av_mallocz(sizeof(*rects[0]));
|
rect = av_mallocz(sizeof(*rect));
|
||||||
if (!rects[sub->num_rects])
|
if (!rect)
|
||||||
return AVERROR(ENOMEM);
|
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);
|
ass_str = ff_ass_get_dialog(readorder, layer, style, speaker, dialog);
|
||||||
if (!ass_str)
|
if (!ass_str)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
rects[sub->num_rects]->ass = ass_str;
|
rect->ass = ass_str;
|
||||||
sub->num_rects++;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user