avformat/mov: fix memleak when spherical info is parsed more than once mov_read_sv3d() and mov_read_vexu_proj() unconditionally assign sc->spherical, leaking the previous allocation when a sample description contains both an sv3d box and a vexu box with a proj child, as in spherical-vexu-orientation.mp4 from the FATE suite. Free any existing structure before allocating a new one. The last box still wins, as before. Signed-off-by: Sathvik Prabhu <sathvik.avenger@gmail.com>
diff --git a/libavformat/mov.c b/libavformat/mov.c index f35334b..eba7619 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c
@@ -7367,6 +7367,7 @@ return 0; } + av_freep(&sc->spherical); sc->spherical = av_spherical_alloc(&sc->spherical_size); if (!sc->spherical) return AVERROR(ENOMEM); @@ -7451,6 +7452,7 @@ return AVERROR_INVALIDDATA; } + av_freep(&sc->spherical); sc->spherical = av_spherical_alloc(&sc->spherical_size); if (!sc->spherical) return AVERROR(ENOMEM);