avformat/oggdec: fix leak in ogg_restore()
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 28 Feb 2017 14:16:54 +0000 (15:16 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 2 Mar 2017 02:12:26 +0000 (03:12 +0100)
Fixes: asan_bug_leak

Found-by: Thomas Guilbert <tguilbert@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/oggdec.c

index 98cd0f5..edeae2b 100644 (file)
@@ -127,8 +127,12 @@ static int ogg_restore(AVFormatContext *s)
 
     ogg->state = ost->next;
 
-        for (i = 0; i < ogg->nstreams; i++)
+        for (i = 0; i < ogg->nstreams; i++) {
             av_freep(&ogg->streams[i].buf);
+            if (i >= ost->nstreams || !ost->streams[i].private) {
+                free_stream(s, i);
+            }
+        }
 
         avio_seek(bc, ost->pos, SEEK_SET);
         ogg->page_pos = -1;