lavc/avpacket: Fix undefined behaviour, do not pass a null pointer to memcpy().
authorCarl Eugen Hoyos <cehoyos@ag.or.at>
Wed, 21 Sep 2016 23:03:55 +0000 (01:03 +0200)
committerCarl Eugen Hoyos <cehoyos@ag.or.at>
Thu, 22 Sep 2016 06:37:46 +0000 (08:37 +0200)
Fixes ticket #5857.

libavcodec/avpacket.c

index a485064..c3f871c 100644 (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;