]> git.puffer.fish Git - matthieu/frr.git/commitdiff
From: Gilad Arnold <gilad.arnold@terayon.com>
authorpaul <paul>
Fri, 16 May 2003 17:19:48 +0000 (17:19 +0000)
committerpaul <paul>
Fri, 16 May 2003 17:19:48 +0000 (17:19 +0000)
Subject: [zebra 19084] Re: suspected memory leakage upon static route

I believe this is a more complete patch, it also addresses
allocating/freeing of nexthop->ifname string buffer (1) using
XSTRDUP/XFREE macros (thus correctly updating memory statistics), and
(2) for all nexthop->type cases that carry an ifname string.

zebra/zebra_rib.c

index f3b9fd65095f9d3f428a9943ab73237c02a10090..1c3819016a55b5b1e60ec4ca892778cf8e4c57cd 100644 (file)
@@ -187,8 +187,8 @@ nexthop_delete (struct rib *rib, struct nexthop *nexthop)
 void
 nexthop_free (struct nexthop *nexthop)
 {
-  if (nexthop->type == NEXTHOP_TYPE_IFNAME && nexthop->ifname)
-    free (nexthop->ifname);
+  if (nexthop->ifname)
+    XFREE (0, nexthop->ifname);
   XFREE (MTYPE_NEXTHOP, nexthop);
 }
 
@@ -215,7 +215,7 @@ nexthop_ifname_add (struct rib *rib, char *ifname)
   nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
   memset (nexthop, 0, sizeof (struct nexthop));
   nexthop->type = NEXTHOP_TYPE_IFNAME;
-  nexthop->ifname = strdup (ifname);
+  nexthop->ifname = XSTRDUP (0, ifname);
 
   nexthop_add (rib, nexthop);