diff options
author | Vignesh Venkatasubramanian <vigneshv@google.com> | 2013-09-02 10:42:22 -0700 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-09-02 21:40:15 +0200 |
commit | fdd1aaf87aaedef00f8b60ad148ccf48226b9d5c (patch) | |
tree | 895a8a2c7db80db9000f7223bbcce5e0efcf88e1 | |
parent | 2501f6d3d6b6e5db58ff4756baf52c69c92f096c (diff) | |
download | ffmpeg-fdd1aaf87aaedef00f8b60ad148ccf48226b9d5c.tar.gz |
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>
-rw-r--r-- | libavcodec/avpacket.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index b6b4109a2c..3469647277 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -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); |