libavformat: Check for malloc failures in avformat_new_stream
authorMartin Storsjö <martin@martin.st>
Sat, 3 Jan 2015 19:27:21 +0000 (21:27 +0200)
committerMartin Storsjö <martin@martin.st>
Sun, 4 Jan 2015 18:04:36 +0000 (20:04 +0200)
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/utils.c

index 3ea0ebd..ce715f7 100644 (file)
@@ -2525,6 +2525,11 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
     }
 
     st->codec = avcodec_alloc_context3(c);
+    if (!st->codec) {
+        av_free(st->info);
+        av_free(st);
+        return NULL;
+    }
     if (s->iformat) {
         /* no default bitrate if decoding */
         st->codec->bit_rate = 0;