diff --git a/deps/media-playback/media-playback/decode.c b/deps/media-playback/media-playback/decode.c
index a3a343c40..0b73fe14c 100644
--- a/deps/media-playback/media-playback/decode.c
+++ b/deps/media-playback/media-playback/decode.c
@@ -251,12 +251,12 @@ void mp_decode_clear_packets(struct mp_decode *d)
 
 void mp_decode_free(struct mp_decode *d)
 {
-	av_packet_free(&d->pkt);
-	av_packet_free(&d->orig_pkt);
-
 	mp_decode_clear_packets(d);
 	circlebuf_free(&d->packets);
 
+	av_packet_free(&d->pkt);
+	av_packet_free(&d->orig_pkt);
+
 	if (d->hw_frame) {
 		av_frame_unref(d->hw_frame);
 		av_free(d->hw_frame);