ffmpeg | branch: release/7.0 | Andreas Rheinhardt 
<andreas.rheinha...@outlook.com> | Fri May 17 20:12:18 2024 +0200| 
[45765b7c2efa9f0dce5dced4ac8ce5a6ec981751] | committer: Andreas Rheinhardt

avformat/flacdec: Reorder allocations to avoid leak on error

Fixes Coverity issue #1591795.

Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com>
(cherry picked from commit b50c5d02900363c17560cf79e2af0ca3073ee81a)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=45765b7c2efa9f0dce5dced4ac8ce5a6ec981751
---

 libavformat/flacdec.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index 4ce6251137..5fe835cd05 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -282,12 +282,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)
@@ -298,6 +292,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;

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to