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 <[email protected]>
Signed-off-by: David Lamparter <[email protected]>
---
 lib/zclient.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/zclient.c b/lib/zclient.c
index ca6a4c7..f25aac1 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -112,6 +112,8 @@ zclient_init (struct zclient *zclient, int redist_default)
 void
 zclient_stop (struct zclient *zclient)
 {
+  int i;
+
   if (zclient_debug)
     zlog_debug ("zclient stopped");
 
@@ -134,6 +136,14 @@ zclient_stop (struct zclient *zclient)
       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
-- 
2.3.6


_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to