avformat/wtvdec: Fix memleak when reading header fails
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 7 Jan 2020 13:55:48 +0000 (14:55 +0100)
committerJames Almer <jamrial@gmail.com>
Wed, 8 Jan 2020 01:35:27 +0000 (22:35 -0300)
Fixes #8314.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: James Almer <jamrial@gmail.com>
libavformat/wtvdec.c

index 706e8ca..92629bb 100644 (file)
@@ -993,8 +993,10 @@ static int read_header(AVFormatContext *s)
     }
 
     ret = parse_chunks(s, SEEK_TO_DATA, 0, 0);
-    if (ret < 0)
+    if (ret < 0) {
+        wtvfile_close(wtv->pb);
         return ret;
+    }
     avio_seek(wtv->pb, -32, SEEK_CUR);
 
     timeline_pos = avio_tell(s->pb); // save before opening another file