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

Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Paul B Mahol 2013-09-16 18:20:08 +00:00
parent 7703d19c40
commit 78f680cb36
1 changed files with 6 additions and 1 deletions

View File

@ -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'));