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

Carl Eugen Hoyos git at videolan.org
Thu Sep 22 09:57:01 EEST 2016


ffmpeg | branch: release/3.1 | Carl Eugen Hoyos <cehoyos at ag.or.at> | Thu Sep 22 01:03:55 2016 +0200| [6fc29572fbf82148e39b18d676688af6d9c17e2f] | committer: Carl Eugen Hoyos

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

Fixes ticket #5857.
(cherry picked from commit c54eef46f990722ed65fd1ad1da3d0fc50806eb5)

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

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

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 92186892..d70ee5d 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;



More information about the ffmpeg-cvslog mailing list