diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2017-02-06 11:17:10 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2017-02-08 20:32:01 +0100 |
commit | 6c1a2e6bc3f0a23b629827f141a644fc646c667e (patch) | |
tree | 28f9b051af591deae87a6fa2c9524fac0c71f97c | |
parent | a4fb905a14c1ab6d14bf38412e7fccbfed09a556 (diff) | |
download | ffmpeg-6c1a2e6bc3f0a23b629827f141a644fc646c667e.tar.gz |
avcodec/movtextdec: Fix decode_styl() cleanup
Fixes: null pointer dereference
Fixes: 555/clusterfuzz-testcase-5986646595993600
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e248522d1b0d6dd8641f382cd5c4338d0ecd98e5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/movtextdec.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index 7b5b161561..81fd1d6deb 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)); |