[FFmpeg-devel,v2,2/8] avformat/libmodplug: fix memleak when load modplug failed

Submitted by Steven Liu on Oct. 10, 2019, 2:07 a.m.

Details

Message ID 20191010020756.30820-2-lq@chinaffmpeg.org
State New
Headers show

Commit Message

Steven Liu Oct. 10, 2019, 2:07 a.m.
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/libmodplug.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavformat/libmodplug.c b/libavformat/libmodplug.c
index 314bdae3e7..d4f78d99b1 100644
--- a/libavformat/libmodplug.c
+++ b/libavformat/libmodplug.c
@@ -216,9 +216,10 @@  static int modplug_read_header(AVFormatContext *s)
     ModPlug_SetSettings(&settings);
 
     modplug->f = ModPlug_Load(modplug->buf, sz);
-    if (!modplug->f)
+    if (!modplug->f) {
+        av_freep(&modplug->buf);
         return AVERROR_INVALIDDATA;
-
+    }
     st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);