diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-03-29 08:50:18 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-04-01 18:23:13 +0200 |
commit | 7aee4762d336a10e5ef51a32a449efaa349e9d07 (patch) | |
tree | ab44bb537806bbebf9b900b5774d0fb51fc27bf7 /libavformat/utils.c | |
parent | 39ecb63d0f082ee3b2ac2ac65577170deb245ec4 (diff) | |
download | ffmpeg-7aee4762d336a10e5ef51a32a449efaa349e9d07.tar.gz |
avformat/utils: Free new streams in ff_add_attached_pic on error
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index c2200d0403..0834c80f4e 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -474,9 +474,10 @@ int avformat_queue_attached_pictures(AVFormatContext *s) return 0; } -int ff_add_attached_pic(AVFormatContext *s, AVStream *st, AVIOContext *pb, +int ff_add_attached_pic(AVFormatContext *s, AVStream *st0, AVIOContext *pb, AVBufferRef **buf, int size) { + AVStream *st = st0; AVPacket *pkt; int ret; @@ -493,7 +494,7 @@ int ff_add_attached_pic(AVFormatContext *s, AVStream *st, AVIOContext *pb, } else { ret = av_get_packet(pb, pkt, size); if (ret < 0) - return ret; + goto fail; } st->disposition |= AV_DISPOSITION_ATTACHED_PIC; st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; @@ -502,6 +503,10 @@ int ff_add_attached_pic(AVFormatContext *s, AVStream *st, AVIOContext *pb, pkt->flags |= AV_PKT_FLAG_KEY; return 0; +fail: + if (!st0) + ff_free_stream(s, st); + return ret; } static int update_stream_avctx(AVFormatContext *s) |