[FFmpeg-cvslog] lavc/avpacket: Fix undefined behaviour, do not pass a null pointer to memcpy().

Carl Eugen Hoyos git at videolan.org
Mon Sep 5 11:16:31 EEST 2016


ffmpeg | branch: master | Carl Eugen Hoyos <cehoyos at ag.or.at> | Sun Sep  4 21:11:02 2016 +0200| [f077ad69c682c13ab75a72aec11a61cac53f0c91] | committer: Carl Eugen Hoyos

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

Fixes ticket #5128.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f077ad69c682c13ab75a72aec11a61cac53f0c91
---

 libavcodec/avpacket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 92186892..fa2844d 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -581,7 +581,8 @@ int av_packet_ref(AVPacket *dst, const AVPacket *src)
         ret = packet_alloc(&dst->buf, src->size);
         if (ret < 0)
             goto fail;
-        memcpy(dst->buf->data, src->data, src->size);
+        if (src->size)
+            memcpy(dst->buf->data, src->data, src->size);
 
         dst->data = dst->buf->data;
     } else {



More information about the ffmpeg-cvslog mailing list