[FFmpeg-devel] [PATCH 03/17] avcodec/movtextdec: add some memory checks

Clément Bœsch u at pkh.me
Sat Sep 20 22:27:43 CEST 2014


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

diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index 05ff53a..deb7553 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -60,7 +60,7 @@ static int mov_text_decode_frame(AVCodecContext *avctx,
                             void *data, int *got_sub_ptr, AVPacket *avpkt)
 {
     AVSubtitle *sub = data;
-    int ts_start, ts_end;
+    int ret, ts_start, ts_end;
     AVBPrint buf;
     const char *ptr = avpkt->data;
     const char *end;
@@ -98,11 +98,13 @@ static int mov_text_decode_frame(AVCodecContext *avctx,
     text_to_ass(&buf, ptr, end);
 
     if (!av_bprint_is_complete(&buf))
-        return AVERROR(ENOMEM);
-
-    ff_ass_add_rect(sub, buf.str, ts_start, ts_end-ts_start, 0);
-    *got_sub_ptr = sub->num_rects > 0;
+        ret = AVERROR(ENOMEM);
+    else
+        ret = ff_ass_add_rect(sub, buf.str, ts_start, ts_end-ts_start, 0);
     av_bprint_finalize(&buf, NULL);
+    if (ret < 0)
+        return ret;
+    *got_sub_ptr = sub->num_rects > 0;
     return avpkt->size;
 }
 
-- 
2.1.0



More information about the ffmpeg-devel mailing list