aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/avpacket.c
diff options
context:
space:
mode:
authorCarl Eugen Hoyos <cehoyos@ag.or.at>2016-09-22 01:03:55 +0200
committerCarl Eugen Hoyos <cehoyos@ag.or.at>2016-09-22 08:37:46 +0200
commitc54eef46f990722ed65fd1ad1da3d0fc50806eb5 (patch)
tree708498ff986e794471c98f00d6313260243a476d /libavcodec/avpacket.c
parent7447ec91b5a692121b81a04c6501a5811d867775 (diff)
downloadffmpeg-c54eef46f990722ed65fd1ad1da3d0fc50806eb5.tar.gz
lavc/avpacket: Fix undefined behaviour, do not pass a null pointer to memcpy().
Fixes ticket #5857.
Diffstat (limited to 'libavcodec/avpacket.c')
-rw-r--r--libavcodec/avpacket.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index a485064eee..c3f871c347 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -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;