lavf/img2dec: Fix memory leak
Fixes #4886 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 01dd7e025c246d9001f1a30f4a5d8fa2936d1a5e)
This commit is contained in:
parent
114c0f002a
commit
2ef386d0a6
@ -444,14 +444,17 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
res = av_new_packet(pkt, size[0] + size[1] + size[2]);
|
res = av_new_packet(pkt, size[0] + size[1] + size[2]);
|
||||||
if (res < 0)
|
if (res < 0) {
|
||||||
return res;
|
goto fail;
|
||||||
|
}
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
pkt->flags |= AV_PKT_FLAG_KEY;
|
pkt->flags |= AV_PKT_FLAG_KEY;
|
||||||
if (s->ts_from_file) {
|
if (s->ts_from_file) {
|
||||||
struct stat img_stat;
|
struct stat img_stat;
|
||||||
if (stat(filename, &img_stat))
|
if (stat(filename, &img_stat)) {
|
||||||
return AVERROR(EIO);
|
res = AVERROR(EIO);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
pkt->pts = (int64_t)img_stat.st_mtime;
|
pkt->pts = (int64_t)img_stat.st_mtime;
|
||||||
#if HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
|
#if HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
|
||||||
if (s->ts_from_file == 2)
|
if (s->ts_from_file == 2)
|
||||||
@ -485,18 +488,29 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
|
|||||||
if (ret[0] <= 0 || ret[1] < 0 || ret[2] < 0) {
|
if (ret[0] <= 0 || ret[1] < 0 || ret[2] < 0) {
|
||||||
av_free_packet(pkt);
|
av_free_packet(pkt);
|
||||||
if (ret[0] < 0) {
|
if (ret[0] < 0) {
|
||||||
return ret[0];
|
res = ret[0];
|
||||||
} else if (ret[1] < 0) {
|
} else if (ret[1] < 0) {
|
||||||
return ret[1];
|
res = ret[1];
|
||||||
} else if (ret[2] < 0)
|
} else if (ret[2] < 0) {
|
||||||
return ret[2];
|
res = ret[2];
|
||||||
return AVERROR_EOF;
|
} else {
|
||||||
|
res = AVERROR_EOF;
|
||||||
|
}
|
||||||
|
goto fail;
|
||||||
} else {
|
} else {
|
||||||
s->img_count++;
|
s->img_count++;
|
||||||
s->img_number++;
|
s->img_number++;
|
||||||
s->pts++;
|
s->pts++;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if (!s->is_pipe) {
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
avio_closep(&f[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int img_read_close(struct AVFormatContext* s1)
|
static int img_read_close(struct AVFormatContext* s1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user