aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Härdin <tomas.hardin@codemill.se>2012-09-07 13:28:48 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-09-07 14:10:19 +0200
commitd74af89317d9e8cabb6a69bfa312957ac5bcfee2 (patch)
treeecec008baea48dee3727d728343fcef3e0e6eab4
parentfa8511851090537f6898fc50d7e6cf56841cf6ab (diff)
downloadffmpeg-d74af89317d9e8cabb6a69bfa312957ac5bcfee2.tar.gz
img2dec: Don't leave AVIOContexts open on zero byte files
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/img2dec.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index cc1faf81bb..d1edf04015 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -330,7 +330,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
char *filename = filename_bytes;
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) {
@@ -352,7 +352,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);
@@ -379,7 +379,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]);