]> git.sesse.net Git - ffmpeg/commitdiff
lavf/avidec: fix memory leak in error handling path
authorJun Zhao <barryjzhao@tencent.com>
Tue, 10 Sep 2019 11:39:27 +0000 (19:39 +0800)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 10 Sep 2019 15:21:54 +0000 (17:21 +0200)
free the value in error handling path to avoid the memory leak.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/avidec.c

index df78925d55423a07d2756c26e75209db716994d2..e3cd844169247d75e1d5ee4076133048096a29ce 100644 (file)
@@ -306,8 +306,10 @@ static int avi_read_tag(AVFormatContext *s, AVStream *st, uint32_t tag,
     value = av_malloc(size + 1);
     if (!value)
         return AVERROR(ENOMEM);
-    if (avio_read(pb, value, size) != size)
+    if (avio_read(pb, value, size) != size) {
+        av_freep(&value);
         return AVERROR_INVALIDDATA;
+    }
     value[size] = 0;
 
     AV_WL32(key, tag);