avpacket: Error out when creating 0-sized side data
authorVittorio Giovara <vittorio.giovara@gmail.com>
Thu, 9 Jun 2016 22:35:03 +0000 (18:35 -0400)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Mon, 13 Jun 2016 17:31:21 +0000 (13:31 -0400)
This mimics the behaviour of other av_*_new_side_data().
This is not caught by the malloc check, since padding
is always added to the allocated size.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
libavcodec/avpacket.c

index 04d6244..76fc4eb 100644 (file)
@@ -265,7 +265,7 @@ uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
     int ret;
     uint8_t *data;
 
-    if ((unsigned)size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
+    if (!size || (unsigned)size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
         return NULL;
     data = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE);
     if (!data)