]> git.puffer.fish Git - matthieu/frr.git/commitdiff
Revert "lib: Fix tab completions memleak, memory stats corruption"
authorDavid Lamparter <equinox@opensourcerouting.org>
Thu, 9 Mar 2017 18:23:00 +0000 (19:23 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Thu, 9 Mar 2017 18:23:00 +0000 (19:23 +0100)
This reverts commit 039dc61292de5f3ed5f46316b1940ab6bb184c3f.

The patch actually made the situation worse since the return value from
cmd_complete_command_real() was now inconsistently allocated from
different memory stat pools.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/command.c

index 6176640bf69917e518d6dafdd99c1efd32a8e7fe..c9b261cf2a7fcdb6de7377e6961da40ca4ac3d39 100644 (file)
@@ -2445,11 +2445,8 @@ cmd_complete_command_real (vector vline, struct vty *vty, int *status, int islib
   /* Only one matched */
   if (vector_slot (matchvec, 1) == NULL)
     {
-      size_t index_size = matchvec->alloced * sizeof (void *);
-      match_str = XMALLOC (MTYPE_TMP, index_size);
-      memcpy (match_str, matchvec->index, index_size);
-      vector_free (matchvec);
-
+      match_str = (char **) matchvec->index;
+      vector_only_wrapper_free (matchvec);
       *status = CMD_COMPLETE_FULL_MATCH;
       return match_str;
     }
@@ -2491,11 +2488,8 @@ cmd_complete_command_real (vector vline, struct vty *vty, int *status, int islib
              /* Make new matchvec. */
              matchvec = vector_init (INIT_MATCHVEC_SIZE);
              vector_set (matchvec, lcdstr);
-
-              size_t index_size = matchvec->alloced * sizeof (void *);
-              match_str = XMALLOC (MTYPE_TMP, index_size);
-              memcpy (match_str, matchvec->index, index_size);
-              vector_free (matchvec);
+              match_str = (char **) matchvec->index;
+              vector_only_wrapper_free (matchvec);
 
              *status = CMD_COMPLETE_MATCH;
              return match_str;