Browse Source

avpacket: Fixing side data copy when src == dst

Fixing av_packet_copy_side_data to work correctly when source and
destination are the same. This makes sure that there is no memory
leak and double frees.

Signed-off by: Vignesh Venkatasubramanian <vigneshv@google.com>

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
tags/n2.1
Vignesh Venkatasubramanian Michael Niedermayer 12 years ago
parent
commit
fdd1aaf87a
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      libavcodec/avpacket.c

+ 4
- 2
libavcodec/avpacket.c View File

@@ -225,8 +225,10 @@ int av_copy_packet_side_data(AVPacket *pkt, AVPacket *src)
int i;
DUP_DATA(pkt->side_data, src->side_data,
src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC);
memset(pkt->side_data, 0,
src->side_data_elems * sizeof(*src->side_data));
if (src != pkt) {
memset(pkt->side_data, 0,
src->side_data_elems * sizeof(*src->side_data));
}
for (i = 0; i < src->side_data_elems; i++) {
DUP_DATA(pkt->side_data[i].data, src->side_data[i].data,
src->side_data[i].size, 1, ALLOC_MALLOC);


Loading…
Cancel
Save