Commit 0ff8cac632 for ffmpeg

commit 0ff8cac632a43229bd8ccca6bfa9e7e2a409ef2f
Author: Michael Niedermayer <michael@niedermayer.cc>
Date:   Tue Oct 13 06:56:14 2026 +0200

    avformat/md5proto: free the MD5 context when opening the output fails

    This is not a security issue.

    Fixes: ORPoDnVi3BLg
    Fixes: swarm-MD5-context-leaked-when-output-URL-open-fails-e4415f

    Found-by: zhang xingxing <2388969553@qq.com>

    Memory leak Replicated through UnModified FFmpeg with LSAN

    Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

diff --git a/libavformat/md5proto.c b/libavformat/md5proto.c
index 653bf10e66..4cf5c3d386 100644
--- a/libavformat/md5proto.c
+++ b/libavformat/md5proto.c
@@ -62,6 +62,7 @@ static int md5_close(URLContext *h)
     int err = 0;

     av_md5_final(c->md5, md5);
+    av_freep(&c->md5);
     ff_data_to_hex(buf, md5, sizeof(md5), 1);
     buf[2 * sizeof(md5)] = '\n';

@@ -80,8 +81,6 @@ static int md5_close(URLContext *h)
             err = AVERROR(errno);
     }

-    av_freep(&c->md5);
-
     return err;
 }