avformat/cache: Fix memleak of tree entries
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 2 Mar 2016 13:09:23 +0000 (14:09 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 27 Apr 2016 02:40:11 +0000 (04:40 +0200)
Found-by: jamrial
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 554f6e930ce05a4c5449efcaae36bdafe2d9de74)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/cache.c

index d3d12bb..7cb6c22 100644 (file)
@@ -282,6 +282,12 @@ resolve_eof:
     return ret;
 }
 
+static int enu_free(void *opaque, void *elem)
+{
+    av_free(elem);
+    return 0;
+}
+
 static int cache_close(URLContext *h)
 {
     Context *c= h->priv_data;
@@ -291,6 +297,7 @@ static int cache_close(URLContext *h)
 
     close(c->fd);
     ffurl_close(c->inner);
+    av_tree_enumerate(c->root, NULL, NULL, enu_free);
     av_tree_destroy(c->root);
 
     return 0;