]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Fix memory leak in matcher
authorQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 13 Sep 2016 18:39:56 +0000 (18:39 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 13 Sep 2016 18:39:56 +0000 (18:39 +0000)
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
lib/command_match.c

index ca2135a1c22f59146bc98e0747173b6c11152c7a..75780de2c52b4599cdb349351955ff56347c00d0 100644 (file)
@@ -94,7 +94,7 @@ command_match (struct graph *cmdgraph,
 
   // prepend a dummy token to match that pesky start node
   vector vvline = vector_init (vline->alloced + 1);
-  vector_set_index (vvline, 0, (void *) "dummy");
+  vector_set_index (vvline, 0, (void *) XSTRDUP (MTYPE_TMP, "dummy"));
   memcpy (vvline->index + 1, vline->index, sizeof (void *) * vline->alloced);
   vvline->active = vline->active + 1;
 
@@ -114,6 +114,11 @@ command_match (struct graph *cmdgraph,
       assert (*el);
     }
 
+  // free the leader token we alloc'd
+  XFREE (MTYPE_TMP, vector_slot (vvline, 0));
+  // free vector
+  vector_free (vvline);
+
   return matcher_rv;
 }