avformat/smacker: use av_malloc_array() and check for allocation error
authorPaul B Mahol <onemda@gmail.com>
Mon, 16 Sep 2013 18:20:08 +0000 (18:20 +0000)
committerPaul B Mahol <onemda@gmail.com>
Tue, 17 Sep 2013 18:29:48 +0000 (18:29 +0000)
Signed-off-by: Paul B Mahol <onemda@gmail.com>
libavformat/smacker.c

index 062195b..7279f95 100644 (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'));