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 df78925..e3cd844 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);