[FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Free buffer in decode_str()

Michael Niedermayer michael at niedermayer.cc
Fri Jun 30 03:16:55 EEST 2023


Fixes: memleak
Fixes: 60058/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-5665259244093440

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavformat/id3v2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 38c86a8e79..69193933e0 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -309,8 +309,10 @@ static int decode_str(AVFormatContext *s, AVIOContext *pb, int encoding,
         avio_w8(dynbuf, 0);
 
     dynsize = avio_close_dyn_buf(dynbuf, dst);
-    if (dynsize <= 0)
+    if (dynsize <= 0) {
+        av_freep(dst);
         return AVERROR(ENOMEM);
+    }
     *maxread = left;
 
     return 0;
-- 
2.17.1



More information about the ffmpeg-devel mailing list