]> git.puffer.fish Git - matthieu/frr.git/commitdiff
Bgpd: aspath json memory leak fix
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 3 Sep 2015 18:26:36 +0000 (11:26 -0700)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 3 Sep 2015 18:26:36 +0000 (11:26 -0700)
Ticket: CM-6790
Reviewed by: CCR-3453
Testing: See bug

This code change fixes these things:

(a) Fixes an assert followed by an if statement
(B) Fixes the memory leak in aspath->json

bgpd/bgp_aspath.c

index a270d8cd763f461458b04ef3fd18af51c9c337c7..c9a6f3fd9efb71adb1daef90a05b87df4f3ad68f 100644 (file)
@@ -710,8 +710,6 @@ aspath_hash_alloc (void *arg)
 
   /* Malformed AS path value. */
   assert (aspath->str);
-  if (! aspath->str)
-    return NULL;
 
   /* New aspath structure is needed. */
   new = XMALLOC (MTYPE_AS_PATH, sizeof (struct aspath));
@@ -860,6 +858,11 @@ aspath_parse (struct stream *s, size_t length, int use32bit)
       assegment_free_all (as.segments);
       /* aspath_key_make() always updates the string */
       XFREE (MTYPE_AS_STR, as.str);
+      if (as.json)
+       {
+         json_object_free(as.json);
+         as.json = NULL;
+       }
     }
 
   find->refcnt++;