From 0ff8cac632a43229bd8ccca6bfa9e7e2a409ef2f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 13 Oct 2026 06:56:14 +0200 Subject: [PATCH] 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 --- libavformat/md5proto.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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; }