mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-23 04:24:35 +02:00
avformat/utils: Free new streams in ff_add_attached_pic on error
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
39ecb63d0f
commit
7aee4762d3
@ -678,6 +678,9 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt);
|
|||||||
* @param buf if set, it contains the data and size information to be used
|
* @param buf if set, it contains the data and size information to be used
|
||||||
* for the attached pic; if unset, data is read from pb.
|
* for the attached pic; if unset, data is read from pb.
|
||||||
* @param size the size of the data to read if buf is unset.
|
* @param size the size of the data to read if buf is unset.
|
||||||
|
*
|
||||||
|
* @return 0 on success, < 0 on error. On error, this function removes
|
||||||
|
* the stream it has added (if any).
|
||||||
*/
|
*/
|
||||||
int ff_add_attached_pic(AVFormatContext *s, AVStream *st, AVIOContext *pb,
|
int ff_add_attached_pic(AVFormatContext *s, AVStream *st, AVIOContext *pb,
|
||||||
AVBufferRef **buf, int size);
|
AVBufferRef **buf, int size);
|
||||||
|
@ -474,9 +474,10 @@ int avformat_queue_attached_pictures(AVFormatContext *s)
|
|||||||
return 0;
|
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)
|
AVBufferRef **buf, int size)
|
||||||
{
|
{
|
||||||
|
AVStream *st = st0;
|
||||||
AVPacket *pkt;
|
AVPacket *pkt;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -493,7 +494,7 @@ int ff_add_attached_pic(AVFormatContext *s, AVStream *st, AVIOContext *pb,
|
|||||||
} else {
|
} else {
|
||||||
ret = av_get_packet(pb, pkt, size);
|
ret = av_get_packet(pb, pkt, size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
goto fail;
|
||||||
}
|
}
|
||||||
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
|
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
|
||||||
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
|
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;
|
pkt->flags |= AV_PKT_FLAG_KEY;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
fail:
|
||||||
|
if (!st0)
|
||||||
|
ff_free_stream(s, st);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int update_stream_avctx(AVFormatContext *s)
|
static int update_stream_avctx(AVFormatContext *s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user