lavc/avpacket: Fix undefined behaviour, do not pass a null pointer to memcpy().

Fixes ticket #5857.
This commit is contained in:
Carl Eugen Hoyos 2016-09-22 01:03:55 +02:00
parent 7447ec91b5
commit c54eef46f9
1 changed files with 2 additions and 1 deletions

View File

@ -139,7 +139,8 @@ int av_grow_packet(AVPacket *pkt, int grow_by)
pkt->buf = av_buffer_alloc(new_size);
if (!pkt->buf)
return AVERROR(ENOMEM);
memcpy(pkt->buf->data, pkt->data, pkt->size);
if (pkt->size > 0)
memcpy(pkt->buf->data, pkt->data, pkt->size);
pkt->data = pkt->buf->data;
}
pkt->size += grow_by;