summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-12-10 22:42:24 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-12-16 02:37:26 +0100
commit2adbb0c2af2cc42a25ab58ef0d4837245f0fbf62 (patch)
tree4cf800b156e0bd649fde263d7ee9c96b92b7f98b
parentcee04cbfe1bf77db5a5bb4ade786573f08a586fc (diff)
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.c12
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;
}