aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2014-09-20 22:00:21 +0200
committerClément Bœsch <u@pkh.me>2014-09-21 18:41:45 +0200
commite833b02f2fb590ce141b9a2a6bef0641d2ecd0a3 (patch)
tree437f8aa5cfda338f7a6a88cf3be41b3bf21e5162
parentac95b436db734cd72e637cef40e11bba2bf5da7d (diff)
downloadffmpeg-e833b02f2fb590ce141b9a2a6bef0641d2ecd0a3.tar.gz
avcodec/movtextdec: add some memory checks
-rw-r--r--libavcodec/movtextdec.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index 05ff53afb4..18cfa949f7 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;
@@ -96,13 +96,11 @@ static int mov_text_decode_frame(AVCodecContext *avctx,
// Note that the spec recommends lines be no longer than 2048 characters.
av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
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 = ff_ass_add_rect_bprint(sub, &buf, 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;
}