[FFmpeg-devel] [PATCH 1/3] libnut: check for av_malloc failure.

Michael Niedermayer michaelni at gmx.at
Wed Dec 7 23:38:16 CET 2011


No, ive no testcase, i just spoted these when looking ...

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavformat/libnut.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/libavformat/libnut.c b/libavformat/libnut.c
index eafe816..9f64544 100644
--- a/libavformat/libnut.c
+++ b/libavformat/libnut.c
@@ -71,6 +71,8 @@ static int nut_write_header(AVFormatContext * avf) {
     int i;
 
     priv->s = s = av_mallocz((avf->nb_streams + 1) * sizeof*s);
+    if(!s)
+        return AVERROR(ENOMEM);
 
     for (i = 0; i < avf->nb_streams; i++) {
         AVCodecContext * codec = avf->streams[i]->codec;
@@ -224,6 +226,10 @@ static int nut_read_header(AVFormatContext * avf, AVFormatParameters * ap) {
         st->codec->extradata_size = s[i].codec_specific_len;
         if (st->codec->extradata_size) {
             st->codec->extradata = av_mallocz(st->codec->extradata_size);
+            if(!st->codec->extradata){
+                nut_demuxer_uninit(nut);
+                return AVERROR(ENOMEM);
+            }
             memcpy(st->codec->extradata, s[i].codec_specific, st->codec->extradata_size);
         }
 
-- 
1.7.5.4



More information about the ffmpeg-devel mailing list