]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
event: remove some one-time memory leaks
authorVincent Bernat <vincent@bernat.im>
Sat, 24 Sep 2016 14:03:03 +0000 (16:03 +0200)
committerVincent Bernat <vincent@bernat.im>
Sat, 24 Sep 2016 14:04:06 +0000 (16:04 +0200)
Also provide a suppression file for valgrind for memory leaks that are
too difficult to remove.

src/daemon/event.c
src/daemon/lldpd.supp [new file with mode: 0644]

index 05c25680339e95ee561d54f87989caa9a6634de1..67e2c878a06307c12708b0d93828a1c61589844b 100644 (file)
@@ -241,6 +241,18 @@ levent_ctl_free_client(struct lldpd_one_client *client)
        }
 }
 
+static void
+levent_ctl_close_clients()
+{
+       struct lldpd_one_client *client, *client_next;
+       for (client = TAILQ_FIRST(&lldpd_clients);
+            client;
+            client = client_next) {
+               client_next = TAILQ_NEXT(client, next);
+               levent_ctl_free_client(client);
+       }
+}
+
 static ssize_t
 levent_ctl_send(struct lldpd_one_client *client, int type, void *data, size_t len)
 {
@@ -585,6 +597,11 @@ levent_loop(struct lldpd *cfg)
                agent_shutdown();
 #endif /* USE_SNMP */
 
+       levent_ctl_close_clients();
+       if (cfg->g_iface_event)
+               event_free(cfg->g_iface_event);
+       if (cfg->g_cleanup_timer)
+               event_free(cfg->g_cleanup_timer);
 }
 
 static void
diff --git a/src/daemon/lldpd.supp b/src/daemon/lldpd.supp
new file mode 100644 (file)
index 0000000..2c97b9a
--- /dev/null
@@ -0,0 +1,18 @@
+# Memory leak when initializing the event loop. Should only happens once.
+{
+   one-time-memory-in-levent-init
+   Memcheck:Leak
+   fun:malloc
+   ...
+   fun:levent_init
+   ...
+}
+
+# Static variable in priv.c
+{
+   static-storage-gethostname
+   Memcheck:Leak
+   fun:realloc
+   fun:priv_gethostname
+   ...
+}