ffmpeg: fix streamcopy with side data

The issue is that, when the main packet data buffer is changed, streamcopy
uses a temporary new packet to store that buffer, frees the old packet, and
replace it with the new packet.

However, in doing so, it forgets about the side data, which gets freed, but
is still needed and referenced. Then, when the packet gets freed again in
the normal code path, it attempts to free its side data which has already
been freed.

Therefore, simply avoid the first free on side data by removing that side
data from the packet.

Fixes ticket #3773.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Christophe Gisquet 2014-08-13 18:40:17 +02:00 committed by Michael Niedermayer
parent 6c1ee1a114
commit 33fefdb449
1 changed files with 2 additions and 0 deletions

View File

@ -627,6 +627,8 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
a = AVERROR(ENOMEM); a = AVERROR(ENOMEM);
} }
if (a > 0) { if (a > 0) {
pkt->side_data = NULL;
pkt->side_data_elems = 0;
av_free_packet(pkt); av_free_packet(pkt);
new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size, new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size,
av_buffer_default_free, NULL, 0); av_buffer_default_free, NULL, 0);