[FFmpeg-cvslog] ass: fix error handling in ff_ass_add_subrect

Marton Balint git at videolan.org
Mon Nov 11 22:35:28 CET 2013


ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Wed Oct 23 11:27:25 2013 +0200| [0f0a8d9859c3ac2a05b0a794197b240b00f3501f] | committer: Marton Balint

ass: fix error handling in ff_ass_add_subrect

Signed-off-by: Marton Balint <cus at passwd.hu>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0f0a8d9859c3ac2a05b0a794197b240b00f3501f
---

 libavcodec/ass.c |   17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/libavcodec/ass.c b/libavcodec/ass.c
index 21d2b8b..ef64b1e 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;
 }



More information about the ffmpeg-cvslog mailing list