[FFmpeg-devel] [PATCH 5/5] lavu/utils: check for malloc failure

wm4 nfxjfg at googlemail.com
Fri Dec 12 18:15:43 CET 2014


---
 libavformat/utils.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 5a2a72d..fc582b7 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3652,6 +3652,10 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
     st->info->last_dts = AV_NOPTS_VALUE;
 
     st->codec = avcodec_alloc_context3(c);
+    if (!st->codec) {
+        av_free(st);
+        return NULL;
+    }
     if (s->iformat) {
         /* no default bitrate if decoding */
         st->codec->bit_rate = 0;
-- 
2.1.1



More information about the ffmpeg-devel mailing list