diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-12-10 22:42:24 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-12-16 02:37:26 +0100 |
commit | 2adbb0c2af2cc42a25ab58ef0d4837245f0fbf62 (patch) | |
tree | 4cf800b156e0bd649fde263d7ee9c96b92b7f98b | |
parent | cee04cbfe1bf77db5a5bb4ade786573f08a586fc (diff) | |
download | ffmpeg-2adbb0c2af2cc42a25ab58ef0d4837245f0fbf62.tar.gz |
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>
-rw-r--r-- | libavcodec/ass.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libavcodec/ass.c b/libavcodec/ass.c index 907e2d7b88..725e4d42ba 100644 --- a/libavcodec/ass.c +++ b/libavcodec/ass.c @@ -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; } |