Commit d74af893 authored by Tomas Härdin's avatar Tomas Härdin Committed by Michael Niedermayer

img2dec: Don't leave AVIOContexts open on zero byte files

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent fa851185
...@@ -330,7 +330,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt) ...@@ -330,7 +330,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
char *filename = filename_bytes; char *filename = filename_bytes;
int i; int i;
int size[3]={0}, ret[3]={0}; int size[3]={0}, ret[3]={0};
AVIOContext *f[3]; AVIOContext *f[3] = {NULL};
AVCodecContext *codec= s1->streams[0]->codec; AVCodecContext *codec= s1->streams[0]->codec;
if (!s->is_pipe) { if (!s->is_pipe) {
...@@ -352,7 +352,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt) ...@@ -352,7 +352,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
for(i=0; i<3; i++){ for(i=0; i<3; i++){
if (avio_open2(&f[i], filename, AVIO_FLAG_READ, if (avio_open2(&f[i], filename, AVIO_FLAG_READ,
&s1->interrupt_callback, NULL) < 0) { &s1->interrupt_callback, NULL) < 0) {
if(i==1) if(i>=1)
break; break;
av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",filename); av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",filename);
return AVERROR(EIO); return AVERROR(EIO);
...@@ -379,7 +379,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt) ...@@ -379,7 +379,7 @@ static int read_packet(AVFormatContext *s1, AVPacket *pkt)
pkt->size= 0; pkt->size= 0;
for(i=0; i<3; i++){ for(i=0; i<3; i++){
if(size[i]){ if(f[i]){
ret[i]= avio_read(f[i], pkt->data + pkt->size, size[i]); ret[i]= avio_read(f[i], pkt->data + pkt->size, size[i]);
if (!s->is_pipe) if (!s->is_pipe)
avio_close(f[i]); avio_close(f[i]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment