diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2017-03-10 14:16:37 +0100 |
|---|---|---|
| committer | David Lamparter <equinox@opensourcerouting.org> | 2017-03-10 14:18:20 +0100 |
| commit | b32cba291bcf4661b5c4853ed76087580ba763eb (patch) | |
| tree | 5516aaa1af2518fb4952c7d05d1babc1dfa8ec44 | |
| parent | e2675fbd5689f2290f5d7b0fb1cd09f58828a3e3 (diff) | |
merge: pre-revert inapplicable changes
The following changes do not apply on master because the code has
changed:
- "vtysh: fix completion"
reverts commit 09e61a383facd3c9e3e52162e98302c7cba15ecc.
- "Revert "lib: Fix tab completions memleak, memory stats corruption""
reverts commit 4dcee34bd603645e53f8a8265dd263a85422b63d.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
| -rw-r--r-- | lib/command.c | 14 | ||||
| -rw-r--r-- | vtysh/vtysh.c | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/command.c b/lib/command.c index c9b261cf2a..6176640bf6 100644 --- a/lib/command.c +++ b/lib/command.c @@ -2445,8 +2445,11 @@ cmd_complete_command_real (vector vline, struct vty *vty, int *status, int islib /* Only one matched */ if (vector_slot (matchvec, 1) == NULL) { - match_str = (char **) matchvec->index; - vector_only_wrapper_free (matchvec); + 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); + *status = CMD_COMPLETE_FULL_MATCH; return match_str; } @@ -2488,8 +2491,11 @@ 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); - match_str = (char **) matchvec->index; - vector_only_wrapper_free (matchvec); + + 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); *status = CMD_COMPLETE_MATCH; return match_str; diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 51f71a46bb..c32e22dda0 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -832,7 +832,7 @@ command_generator (const char *text, int state) vector_set (vline, NULL); if (matched) - vector_only_index_free (matched); + XFREE (MTYPE_TMP, matched); matched = cmd_complete_command (vline, vty, &complete_status); cmd_free_strvec (vline); } |
