diff options
author | Marton Balint <cus@passwd.hu> | 2013-10-23 11:27:25 +0200 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2013-11-10 18:57:51 +0100 |
commit | 0f0a8d9859c3ac2a05b0a794197b240b00f3501f (patch) | |
tree | b4c3584d754131dba066628afd6fab5eeed115ba | |
parent | f148954b0ac11123e47eedf24abb99366dc9a3ad (diff) | |
download | ffmpeg-0f0a8d9859c3ac2a05b0a794197b240b00f3501f.tar.gz |
ass: fix error handling in ff_ass_add_subrect
Signed-off-by: Marton Balint <cus@passwd.hu>
-rw-r--r-- | libavcodec/ass.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/libavcodec/ass.c b/libavcodec/ass.c index 21d2b8b380..ef64b1ecd6 100644 --- a/libavcodec/ass.c +++ b/libavcodec/ass.c @@ -123,21 +123,28 @@ int ff_ass_add_rect(AVSubtitle *sub, const char *dialog, AVSubtitleRect **rects; av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED); - if ((dlen = ff_ass_bprint_dialog(&buf, dialog, ts_start, duration, raw)) < 0) - return dlen; + if ((ret = ff_ass_bprint_dialog(&buf, dialog, ts_start, duration, raw)) < 0) + goto err; + dlen = ret; if (!av_bprint_is_complete(&buf)) - return AVERROR(ENOMEM); + goto errnomem; rects = av_realloc(sub->rects, (sub->num_rects+1) * sizeof(*sub->rects)); if (!rects) - return AVERROR(ENOMEM); + goto errnomem; sub->rects = rects; sub->end_display_time = FFMAX(sub->end_display_time, 10 * duration); rects[sub->num_rects] = av_mallocz(sizeof(*rects[0])); rects[sub->num_rects]->type = SUBTITLE_ASS; ret = av_bprint_finalize(&buf, &rects[sub->num_rects]->ass); if (ret < 0) - return ret; + goto err; sub->num_rects++; return dlen; + +errnomem: + ret = AVERROR(ENOMEM); +err: + av_bprint_finalize(&buf, NULL); + return ret; } |