1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-08 13:22:53 +02:00

avcodec/avpacket: clear side_data_elems

Fixes null pointer dereference

Found-by: 连一汉 <lianyihan@360.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2016-09-12 13:13:42 +02:00
parent dca03ec5f4
commit 5e1bf9d8c0

View File

@ -198,6 +198,7 @@ static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
{ {
pkt->data = NULL; pkt->data = NULL;
pkt->side_data = NULL; pkt->side_data = NULL;
pkt->side_data_elems = 0;
if (pkt->buf) { if (pkt->buf) {
AVBufferRef *ref = av_buffer_ref(src->buf); AVBufferRef *ref = av_buffer_ref(src->buf);
if (!ref) if (!ref)
@ -207,9 +208,11 @@ static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
} else { } else {
DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF); DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF);
} }
if (pkt->side_data_elems && dup) if (src->side_data_elems && dup) {
pkt->side_data = src->side_data; pkt->side_data = src->side_data;
if (pkt->side_data_elems && !dup) { pkt->side_data_elems = src->side_data_elems;
}
if (src->side_data_elems && !dup) {
return av_copy_packet_side_data(pkt, src); return av_copy_packet_side_data(pkt, src);
} }
return 0; return 0;