diff --git a/libavformat/mov.c b/libavformat/mov.c
index 248faf73a1ae14ec42d632b5b8eaf8c61196c0aa..19ec11f9684aea8fb7cc9ee8ea68964df8fe5e84 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3754,7 +3754,7 @@ static int mov_read_close(AVFormatContext *s)
         sc->drefs_count = 0;
 
         if (!sc->pb_is_copied)
-            avio_close(sc->pb);
+            avio_closep(&sc->pb);
 
         sc->pb = NULL;
         av_freep(&sc->chunk_offsets);