diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 346964727781f6fca72a875ab9c012d5a26c7f58..b388d5e7bd53c173a1214971e1ebf05e8756f885 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -309,7 +309,7 @@ uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
     if (!pkt->side_data)
         return NULL;
 
-    pkt->side_data[elems].data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
+    pkt->side_data[elems].data = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE);
     if (!pkt->side_data[elems].data)
         return NULL;
     pkt->side_data[elems].size = size;