aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-05-17 20:12:18 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-05-20 14:15:18 +0200
commitb50c5d02900363c17560cf79e2af0ca3073ee81a (patch)
tree92b64c42fbeb330c197648129e0a04a85320d52d
parent59b1838e0955bb092ebc9d6e9f8aa7d8753d4d33 (diff)
downloadffmpeg-b50c5d02900363c17560cf79e2af0ca3073ee81a.tar.gz
avformat/flacdec: Reorder allocations to avoid leak on error
Fixes Coverity issue #1591795. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r--libavformat/flacdec.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index 3d35da5fea..3c317acaee 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -283,12 +283,6 @@ static av_unused int64_t flac_read_timestamp(AVFormatContext *s, int stream_inde
if (avio_seek(s->pb, *ppos, SEEK_SET) < 0)
return AV_NOPTS_VALUE;
- parser = av_parser_init(st->codecpar->codec_id);
- if (!parser){
- return AV_NOPTS_VALUE;
- }
- parser->flags |= PARSER_FLAG_USE_CODEC_TS;
-
if (!flac->parser_dec) {
flac->parser_dec = avcodec_alloc_context3(NULL);
if (!flac->parser_dec)
@@ -299,6 +293,11 @@ static av_unused int64_t flac_read_timestamp(AVFormatContext *s, int stream_inde
return ret;
}
+ parser = av_parser_init(st->codecpar->codec_id);
+ if (!parser)
+ return AV_NOPTS_VALUE;
+ parser->flags |= PARSER_FLAG_USE_CODEC_TS;
+
for (;;){
uint8_t *data;
int size;