[FFmpeg-devel] [PATCH]Fix crash on OOM

Carl Eugen Hoyos cehoyos at ag.or.at
Thu Jun 27 00:18:25 CEST 2013


Hi!

Attached patch fixes a null-pointer-dereference in avcodec_decode_video2() 
because of OOM as reported in ticket 1900.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 71fca24..4f14429 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2674,9 +2674,12 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
 
         //try to just open decoders, in case this is enough to get parameters
         if (!has_codec_parameters(st, NULL) && st->request_probe <= 0) {
-            if (codec && !st->codec->codec)
-                avcodec_open2(st->codec, codec, options ? &options[i]
+            if (codec && !st->codec->codec) {
+                ret = avcodec_open2(st->codec, codec, options ? &options[i]
                               : &thread_opt);
+                if (ret < 0)
+                    goto find_stream_info_err;
+            }
         }
         if (!options)
             av_dict_free(&thread_opt);


More information about the ffmpeg-devel mailing list