summaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2019-10-11 14:34:17 -0300
committerJames Almer <jamrial@gmail.com>2019-10-11 20:38:36 -0300
commit72704cbff4257466662729fc20e3f0ab85aa8c9e (patch)
treeae896597439e7acc5558934e32596b8a17793a33 /libavformat
parent27da30adddc6f9c5fcbc0d3a0b791db061d179cf (diff)
downloadffmpeg-streaming-72704cbff4257466662729fc20e3f0ab85aa8c9e.zip
ffmpeg-streaming-72704cbff4257466662729fc20e3f0ab85aa8c9e.tar.gz
avformat/dv: free all allocated structs on dv_read_header failure
Also propagate proper AVERROR codes while at it. Fixes ticket #8230. Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/dv.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/libavformat/dv.c b/libavformat/dv.c
index eb44e0a..e99422d 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -495,16 +495,18 @@ static int dv_read_header(AVFormatContext *s)
{
unsigned state, marker_pos = 0;
RawDVContext *c = s->priv_data;
+ int ret;
c->dv_demux = avpriv_dv_init_demux(s);
if (!c->dv_demux)
- return -1;
+ return AVERROR(ENOMEM);
state = avio_rb32(s->pb);
while ((state & 0xffffff7f) != 0x1f07003f) {
if (avio_feof(s->pb)) {
av_log(s, AV_LOG_ERROR, "Cannot find DV header.\n");
- return -1;
+ ret = AVERROR_INVALIDDATA;
+ goto fail;
}
if (state == 0x003f0700 || state == 0xff3f0700)
marker_pos = avio_tell(s->pb);
@@ -518,8 +520,10 @@ static int dv_read_header(AVFormatContext *s)
AV_WB32(c->buf, state);
if (avio_read(s->pb, c->buf + 4, DV_PROFILE_BYTES - 4) != DV_PROFILE_BYTES - 4 ||
- avio_seek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0)
- return AVERROR(EIO);
+ avio_seek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0) {
+ ret = AVERROR(EIO);
+ goto fail;
+ }
c->dv_demux->sys = av_dv_frame_profile(c->dv_demux->sys,
c->buf,
@@ -527,7 +531,8 @@ static int dv_read_header(AVFormatContext *s)
if (!c->dv_demux->sys) {
av_log(s, AV_LOG_ERROR,
"Can't determine profile of DV input stream.\n");
- return -1;
+ ret = AVERROR_INVALIDDATA;
+ goto fail;
}
s->bit_rate = av_rescale_q(c->dv_demux->sys->frame_size,
@@ -538,6 +543,11 @@ static int dv_read_header(AVFormatContext *s)
dv_read_timecode(s);
return 0;
+
+fail:
+ av_freep(&c->dv_demux);
+
+ return ret;
}
static int dv_read_packet(AVFormatContext *s, AVPacket *pkt)
OpenPOWER on IntegriCloud