[FFmpeg-cvslog] avformat/smacker: use av_malloc_array() and check for allocation error

Paul B Mahol git at videolan.org
Tue Sep 17 20:31:41 CEST 2013


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Sep 16 18:20:08 2013 +0000| [78f680cb3664624fedc00d03b0cd77255da2776b] | committer: Paul B Mahol

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

Signed-off-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=78f680cb3664624fedc00d03b0cd77255da2776b
---

 libavformat/smacker.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavformat/smacker.c b/libavformat/smacker.c
index 062195b..7279f95 100644
--- a/libavformat/smacker.c
+++ b/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'));
 



More information about the ffmpeg-cvslog mailing list