chiark / gitweb /
journal: fix hashmap leak in mmap-cache
authorGeorge McCollister <george.mccollister@gmail.com>
Thu, 1 Aug 2013 17:40:01 +0000 (12:40 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 2 Aug 2013 15:25:45 +0000 (11:25 -0400)
hashmap_free() wasn't being called on m->contexts and m->fds resulting
in a leak.

To reproduce do:
while(1) {
sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY);
sd_journal_close(j);
}

Memory usage will increase until OOM.

src/journal/mmap-cache.c

index 767f5555265c7e73aee0c94ec83e0b51788a5baa..03b57beb046fc72019116ea368dc72ccc6cf0872 100644 (file)
@@ -307,9 +307,13 @@ static void mmap_cache_free(MMapCache *m) {
         while ((c = hashmap_first(m->contexts)))
                 context_free(c);
 
+        hashmap_free(m->contexts);
+
         while ((f = hashmap_first(m->fds)))
                 fd_free(f);
 
+        hashmap_free(m->fds);
+
         while (m->unused)
                 window_free(m->unused);