avformat/matroskadec: use av_malloc_array() and check for allocation error
authorPaul B Mahol <onemda@gmail.com>
Mon, 16 Sep 2013 18:03:27 +0000 (18:03 +0000)
committerPaul B Mahol <onemda@gmail.com>
Thu, 19 Sep 2013 22:28:25 +0000 (22:28 +0000)
Signed-off-by: Paul B Mahol <onemda@gmail.com>
libavformat/matroskadec.c

index 76c610b..8bbbf68 100644 (file)
@@ -1770,7 +1770,9 @@ static int matroska_read_header(AVFormatContext *s)
                 track->audio.sub_packet_h <= 0 || track->audio.frame_size <= 0 ||
                 track->audio.sub_packet_size <= 0)
                 return AVERROR_INVALIDDATA;
-            track->audio.buf = av_malloc(track->audio.frame_size * track->audio.sub_packet_h);
+            track->audio.buf = av_malloc_array(track->audio.sub_packet_h, track->audio.frame_size);
+            if (!track->audio.buf)
+                return AVERROR(ENOMEM);
             if (codec_id == AV_CODEC_ID_RA_288) {
                 st->codec->block_align = track->audio.coded_framesize;
                 track->codec_priv.size = 0;