Check for failed extradata malloc, fixes a crash in out-of-memory conditions
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>
Fri, 3 Jul 2009 11:27:52 +0000 (11:27 +0000)
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>
Fri, 3 Jul 2009 11:27:52 +0000 (11:27 +0000)
or with extremely large extradata.

Originally committed as revision 19333 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavformat/avidec.c

index 5b7c8bb..56b6204 100644 (file)
@@ -483,6 +483,10 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
                     if(size > 10*4 && size<(1<<30)){
                         st->codec->extradata_size= size - 10*4;
                         st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+                        if (!st->codec->extradata) {
+                            st->codec->extradata_size= 0;
+                            return AVERROR(ENOMEM);
+                        }
                         get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
                     }