[FFmpeg-devel] [PATCH] avformat/matroskadec: use av_malloc_array() and check for allocation error

Paul B Mahol onemda at gmail.com
Mon Sep 16 20:28:49 CEST 2013


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavformat/matroskadec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 86351df..d903bfe 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1766,7 +1766,9 @@ static int matroska_read_header(AVFormatContext *s)
             track->audio.sub_packet_h    = avio_rb16(&b);
             track->audio.frame_size      = avio_rb16(&b);
             track->audio.sub_packet_size = avio_rb16(&b);
-            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;
-- 
1.7.11.2



More information about the ffmpeg-devel mailing list