avformat/smacker: use av_malloc_array() and check for allocation error

Signed-off-by: Paul B Mahol <onemda@gmail.com>
pull/36/head
Paul B Mahol 12 years ago
parent 7703d19c40
commit 78f680cb36
  1. 7
      libavformat/smacker.c

@ -142,8 +142,13 @@ static int smacker_read_header(AVFormatContext *s)
av_log(s, AV_LOG_ERROR, "Too many frames: %i\n", smk->frames);
return AVERROR_INVALIDDATA;
}
smk->frm_size = av_malloc(smk->frames * 4);
smk->frm_size = av_malloc_array(smk->frames, sizeof(*smk->frm_size));
smk->frm_flags = av_malloc(smk->frames);
if (!smk->frm_size || !smk->frm_flags) {
av_freep(&smk->frm_size);
av_freep(&smk->frm_flags);
return AVERROR(ENOMEM);
}
smk->is_ver4 = (smk->magic != MKTAG('S', 'M', 'K', '2'));

Loading…
Cancel
Save