yop: only set extradata size after it has been successfully allocated
authorAnton Khirnov <anton@khirnov.net>
Sat, 3 May 2014 08:48:03 +0000 (10:48 +0200)
committerAnton Khirnov <anton@khirnov.net>
Sun, 18 May 2014 08:22:42 +0000 (10:22 +0200)
Do not leave a non-zero extradata_size set on failure

libavformat/yop.c

index 8caeb07..ea3175e 100644 (file)
@@ -62,13 +62,12 @@ static int yop_read_header(AVFormatContext *s)
     video_stream = avformat_new_stream(s, NULL);
 
     // Extra data that will be passed to the decoder
-    video_stream->codec->extradata_size = 8;
 
-    video_stream->codec->extradata = av_mallocz(video_stream->codec->extradata_size +
-                                                FF_INPUT_BUFFER_PADDING_SIZE);
+    video_stream->codec->extradata = av_mallocz(8 + FF_INPUT_BUFFER_PADDING_SIZE);
 
     if (!video_stream->codec->extradata)
         return AVERROR(ENOMEM);
+    video_stream->codec->extradata_size = 8;
 
     // Audio
     audio_dec               = audio_stream->codec;