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, 2 Mar 2016 13:27:57 +0000 (14:27 +0100)
Found-by: jamrial
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/cache.c

index 2889e3b..59d7fe6 100644 (file)
@@ -283,6 +283,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;
@@ -292,6 +298,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;