Browse code

libnut: check for av_malloc failure.

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

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2011/11/28 13:23:48
Showing 1 changed files
... ...
@@ -71,6 +71,8 @@ static int nut_write_header(AVFormatContext * avf) {
71 71
     int i;
72 72
 
73 73
     priv->s = s = av_mallocz((avf->nb_streams + 1) * sizeof*s);
74
+    if(!s)
75
+        return AVERROR(ENOMEM);
74 76
 
75 77
     for (i = 0; i < avf->nb_streams; i++) {
76 78
         AVCodecContext * codec = avf->streams[i]->codec;
... ...
@@ -224,6 +226,10 @@ static int nut_read_header(AVFormatContext * avf, AVFormatParameters * ap) {
224 224
         st->codec->extradata_size = s[i].codec_specific_len;
225 225
         if (st->codec->extradata_size) {
226 226
             st->codec->extradata = av_mallocz(st->codec->extradata_size);
227
+            if(!st->codec->extradata){
228
+                nut_demuxer_uninit(nut);
229
+                return AVERROR(ENOMEM);
230
+            }
227 231
             memcpy(st->codec->extradata, s[i].codec_specific, st->codec->extradata_size);
228 232
         }
229 233