Fixes: asan_bug_leak

Found-by: Thomas Guilbert <tguilb...@google.com>
Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>
---
 libavformat/oggdec.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 98cd0f55c7..edeae2ba83 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -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;
-- 
2.11.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to