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>
pull/74/merge
Christophe Gisquet 10 years ago committed by Michael Niedermayer
parent 6c1ee1a114
commit 33fefdb449
  1. 2
      ffmpeg.c

@ -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);

Loading…
Cancel
Save