summaryrefslogtreecommitdiff
path: root/libavformat/ape.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2020-03-21 18:31:06 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-07-07 21:26:43 +0200
commit58da6b18a3d2f11b0f7a1bb80beda19cdf267431 (patch)
treea185d4f3bae5a94e58e14bce54ca320de194e66d /libavformat/ape.c
parent609672a4a3344b511204a490c817c67ba99b3c79 (diff)
downloadffmpeg-58da6b18a3d2f11b0f7a1bb80beda19cdf267431.tar.gz
avformat/ape: Simplify cleanup after read_header failure
by setting the FF_FMT_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/ape.c')
-rw-r--r--libavformat/ape.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/libavformat/ape.c b/libavformat/ape.c
index a4cfd01807..b6f9be4dbc 100644
--- a/libavformat/ape.c
+++ b/libavformat/ape.c
@@ -79,8 +79,6 @@ typedef struct APEContext {
uint32_t samplerate;
} APEContext;
-static int ape_read_close(AVFormatContext * s);
-
static int ape_probe(const AVProbeData * p)
{
int version = AV_RL16(p->buf+4);
@@ -276,8 +274,7 @@ static int ape_read_header(AVFormatContext * s)
if (pb->eof_reached) {
av_log(s, AV_LOG_ERROR, "seektable truncated\n");
- ret = AVERROR_INVALIDDATA;
- goto fail;
+ return AVERROR_INVALIDDATA;
}
ff_dlog(s, "seektable: %8d %"PRIu32"\n", i, seektable_entry);
}
@@ -313,8 +310,7 @@ static int ape_read_header(AVFormatContext * s)
ff_dlog(s, "bittable: %2d\n", bits);
if (pb->eof_reached) {
av_log(s, AV_LOG_ERROR, "bittable truncated\n");
- ret = AVERROR_INVALIDDATA;
- goto fail;
+ return AVERROR_INVALIDDATA;
}
}
}
@@ -327,10 +323,8 @@ static int ape_read_header(AVFormatContext * s)
/* now we are ready: build format streams */
st = avformat_new_stream(s, NULL);
- if (!st) {
- ret = AVERROR(ENOMEM);
- goto fail;
- }
+ if (!st)
+ return AVERROR(ENOMEM);
total_blocks = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks;
@@ -347,7 +341,7 @@ static int ape_read_header(AVFormatContext * s)
avpriv_set_pts_info(st, 64, 1, ape->samplerate);
if ((ret = ff_alloc_extradata(st->codecpar, APE_EXTRADATA_SIZE)) < 0)
- goto fail;
+ return ret;
AV_WL16(st->codecpar->extradata + 0, ape->fileversion);
AV_WL16(st->codecpar->extradata + 2, ape->compressiontype);
AV_WL16(st->codecpar->extradata + 4, ape->formatflags);
@@ -366,10 +360,6 @@ static int ape_read_header(AVFormatContext * s)
}
return 0;
-fail:
- ape_read_close(s);
-
- return ret;
}
static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
@@ -454,6 +444,7 @@ const AVInputFormat ff_ape_demuxer = {
.name = "ape",
.long_name = NULL_IF_CONFIG_SMALL("Monkey's Audio"),
.priv_data_size = sizeof(APEContext),
+ .flags_internal = FF_FMT_INIT_CLEANUP,
.read_probe = ape_probe,
.read_header = ape_read_header,
.read_packet = ape_read_packet,