[FFmpeg-cvslog] img2dec: always close AVIOContexts

Tomas Härdin git at videolan.org
Thu Sep 13 15:29:02 CEST 2012


ffmpeg | branch: master | Tomas Härdin <tomas.hardin at codemill.se> | Fri Sep  7 13:28:48 2012 +0200| [5e3572893d7f17679c5e051c511bf42f3da77b00] | committer: Luca Barbato

img2dec: always close AVIOContexts

Zero sized files would cause the contexts to leak away.

Signed-off-by: Luca Barbato <lu_zero at gentoo.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5e3572893d7f17679c5e051c511bf42f3da77b00
---

 libavformat/img2dec.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 2f5092f..1151180 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -216,7 +216,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
     char filename[1024];
     int i;
     int size[3]={0}, ret[3]={0};
-    AVIOContext *f[3];
+    AVIOContext *f[3] = {NULL};
     AVCodecContext *codec= s1->streams[0]->codec;
 
     if (!s->is_pipe) {
@@ -232,7 +232,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
         for(i=0; i<3; i++){
             if (avio_open2(&f[i], filename, AVIO_FLAG_READ,
                            &s1->interrupt_callback, NULL) < 0) {
-                if(i==1)
+                if(i>=1)
                     break;
                 av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",filename);
                 return AVERROR(EIO);
@@ -259,7 +259,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
 
     pkt->size= 0;
     for(i=0; i<3; i++){
-        if(size[i]){
+        if(f[i]){
             ret[i]= avio_read(f[i], pkt->data + pkt->size, size[i]);
             if (!s->is_pipe)
                 avio_close(f[i]);



More information about the ffmpeg-cvslog mailing list