[FFmpeg-devel,v2,8/8] avformat/wc3movie: fix memleak when read content size not equvipe input size

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

Details

Message ID 20191010020756.30820-8-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/wc3movie.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Oct. 11, 2019, 8:13 p.m.
Hi

typo in commit message "equvipe"

otherwise LGTM

thx

[...]

Patch hide | download patch | download mbox

diff --git a/libavformat/wc3movie.c b/libavformat/wc3movie.c
index 27f5eb1962..6577007777 100644
--- a/libavformat/wc3movie.c
+++ b/libavformat/wc3movie.c
@@ -130,8 +130,10 @@  static int wc3_read_header(AVFormatContext *s)
             buffer = av_malloc(size+1);
             if (!buffer)
                 return AVERROR(ENOMEM);
-            if ((ret = avio_read(pb, buffer, size)) != size)
+            if ((ret = avio_read(pb, buffer, size)) != size) {
+                av_freep(&buffer);
                 return AVERROR(EIO);
+            }
             buffer[size] = 0;
             av_dict_set(&s->metadata, "title", buffer,
                                    AV_DICT_DONT_STRDUP_VAL);