diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 9978712bb839e69179542c80628e39ed2646f39e..3c26046dad1ec862f1b07afa070f2c1c255d55b4 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -272,7 +272,7 @@ void av_packet_free_side_data(AVPacket *pkt)
 {
     int i;
     for (i = 0; i < pkt->side_data_elems; i++)
-        av_free(pkt->side_data[i].data);
+        av_freep(&pkt->side_data[i].data);
     av_freep(&pkt->side_data);
     pkt->side_data_elems = 0;
 }