mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-07 23:32:33 +00:00
avformat/matroskadec: Move AVBufferRef instead of copying, fix memleak
EBML binary elements are already made reference-counted when read; so when populating the AVStream.attached_pic, one does not need to allocate a new buffer for the data; instead the current code just creates a new reference to the underlying AVBuffer. But this can be improved even further: Just move the already existing reference. This also fixes a memleak that happens upon error because matroska_read_close has not been called in this scenario. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
parent
b737575c76
commit
cbe336c9e8
@ -2938,9 +2938,8 @@ static int matroska_read_header(AVFormatContext *s)
|
||||
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||
|
||||
av_init_packet(pkt);
|
||||
pkt->buf = av_buffer_ref(attachments[j].bin.buf);
|
||||
if (!pkt->buf)
|
||||
return AVERROR(ENOMEM);
|
||||
pkt->buf = attachments[j].bin.buf;
|
||||
attachments[j].bin.buf = NULL;
|
||||
pkt->data = attachments[j].bin.data;
|
||||
pkt->size = attachments[j].bin.size;
|
||||
pkt->stream_index = st->index;
|
||||
|
Loading…
Reference in New Issue
Block a user