X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=libavcodec%2Fmovtextdec.c;h=fb5085c3e8222e48d680079d3a6d14b112741492;hb=55eab1733b9e730ceac33edce9aab56c17ea87b2;hp=7b5b161561dc87186b0866ab5d6ff08cc4c298a3;hpb=7e9474ca47fd4d267bdafcc8162fded67f6410e5;p=ffmpeg diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index 7b5b161561d..fb5085c3e82 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -116,6 +116,8 @@ static void mov_text_cleanup(MovTextContext *m) av_freep(&m->s[i]); } av_freep(&m->s); + m->count_s = 0; + m->style_entries = 0; } } @@ -279,12 +281,14 @@ static int decode_hclr(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt) static int decode_styl(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt) { int i; - m->style_entries = AV_RB16(tsmb); + int style_entries = AV_RB16(tsmb); tsmb += 2; // A single style record is of length 12 bytes. - if (m->tracksize + m->size_var + 2 + m->style_entries * 12 > avpkt->size) + if (m->tracksize + m->size_var + 2 + style_entries * 12 > avpkt->size) return -1; + m->style_entries = style_entries; + m->box_flags |= STYL_BOX; for(i = 0; i < m->style_entries; i++) { m->s_temp = av_malloc(sizeof(*m->s_temp)); @@ -455,6 +459,8 @@ static int mov_text_decode_frame(AVCodecContext *avctx, end = ptr + FFMIN(2 + text_length, avpkt->size); ptr += 2; + mov_text_cleanup(m); + tsmb_size = 0; m->tracksize = 2 + text_length; m->style_entries = 0; @@ -517,6 +523,7 @@ static int mov_text_decode_close(AVCodecContext *avctx) { MovTextContext *m = avctx->priv_data; mov_text_cleanup_ftab(m); + mov_text_cleanup(m); return 0; }