[FFmpeg-cvslog] flacdec: don' t create an attached picture stream	until we have all information.
    Anton Khirnov 
    git at videolan.org
       
    Sun Jul  8 22:38:55 CEST 2012
    
    
  
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Fri Jul  6 22:21:09 2012 +0200| [dba5b06ead6bbec8fd1207d778240188182c8361] | committer: Anton Khirnov
flacdec: don't create an attached picture stream until we have all information.
This way we don't end with an invalid stream if parsing the picture
fails.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dba5b06ead6bbec8fd1207d778240188182c8361
---
 libavformat/flacdec.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index f481c10..0be60a4 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -38,10 +38,6 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
     int type, width, height;
     int len, ret = 0;
 
-    st = avformat_new_stream(s, NULL);
-    if (!st)
-        return AVERROR(ENOMEM);
-
     pb = avio_alloc_context(buf, buf_size, 0, NULL, NULL, NULL, NULL);
     if (!pb)
         return AVERROR(ENOMEM);
@@ -114,6 +110,12 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
         goto fail;
     }
 
+    st = avformat_new_stream(s, NULL);
+    if (!st) {
+        ret = AVERROR(ENOMEM);
+        goto fail;
+    }
+
     av_init_packet(&st->attached_pic);
     st->attached_pic.data         = data;
     st->attached_pic.size         = len;
    
    
More information about the ffmpeg-cvslog
mailing list