Commit e248522d authored by Michael Niedermayer's avatar Michael Niedermayer

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/ffmpegSigned-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 4fcdc9f3
...@@ -116,6 +116,8 @@ static void mov_text_cleanup(MovTextContext *m) ...@@ -116,6 +116,8 @@ static void mov_text_cleanup(MovTextContext *m)
av_freep(&m->s[i]); av_freep(&m->s[i]);
} }
av_freep(&m->s); 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) ...@@ -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) static int decode_styl(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt)
{ {
int i; int i;
m->style_entries = AV_RB16(tsmb); int style_entries = AV_RB16(tsmb);
tsmb += 2; tsmb += 2;
// A single style record is of length 12 bytes. // 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; return -1;
m->style_entries = style_entries;
m->box_flags |= STYL_BOX; m->box_flags |= STYL_BOX;
for(i = 0; i < m->style_entries; i++) { for(i = 0; i < m->style_entries; i++) {
m->s_temp = av_malloc(sizeof(*m->s_temp)); m->s_temp = av_malloc(sizeof(*m->s_temp));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment