lavc/avpacket: Fix undefined behaviour, do not pass a null pointer to memcpy().
authorCarl Eugen Hoyos <cehoyos@ag.or.at>
Sun, 4 Sep 2016 19:11:02 +0000 (21:11 +0200)
committerCarl Eugen Hoyos <cehoyos@ag.or.at>
Mon, 5 Sep 2016 08:16:03 +0000 (10:16 +0200)
Fixes ticket #5128.

libavcodec/avpacket.c

index 9218689..fa2844d 100644 (file)
@@ -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 {