lib: fix vrf_bitmap leak in zclient_free()
zclient_stop(), which is used as antagonist to zclient_init(), needs to
undo the vrf_bitmap allocation. Otherwise zclient_init() will leak the
allocated memory, for example when zclient_reset() is used.
Reported-by: Lou Berger <lberger@labn.net>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/lib/zclient.c b/lib/zclient.c
index d25c8d4..9d50ebc 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -112,6 +112,8 @@
void
zclient_stop (struct zclient *zclient)
{
+ int i;
+
if (zclient_debug)
zlog_debug ("zclient stopped");
@@ -134,6 +136,14 @@
zclient->sock = -1;
}
zclient->fail = 0;
+
+ for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
+ {
+ vrf_bitmap_free(zclient->redist[i]);
+ zclient->redist[i] = VRF_BITMAP_NULL;
+ }
+ vrf_bitmap_free(zclient->default_information);
+ zclient->default_information = VRF_BITMAP_NULL;
}
void