From 047213b01e786c9765460fccd5f394e93fc777f1 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 3 Jul 2013 09:32:37 +0200 Subject: [PATCH] vty: Attempt to fix various meam leaks in the VTY lookup code These routines were not freeing vectors used for the lookup. On review it is fixing another path not detected by coverity. The danger is a double free in tab completion now. It is difficult to test this. Fixes: Coverity CID 23037, CID 23038 --- src/vty/command.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/vty/command.c b/src/vty/command.c index 4f47a6bee..faa7c51c2 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -1574,10 +1574,12 @@ cmd_describe_command_real(vector vline, struct vty *vty, int *status) if ((ret = is_cmd_ambiguous(command, cmd_vector, i, match)) == 1) { vector_free(cmd_vector); + vector_free(matchvec); *status = CMD_ERR_AMBIGUOUS; return NULL; } else if (ret == 2) { vector_free(cmd_vector); + vector_free(matchvec); *status = CMD_ERR_NO_MATCH; return NULL; } @@ -1724,6 +1726,7 @@ static char **cmd_complete_command_real(vector vline, struct vty *vty, if (vector_active(vline) == 0) { *status = CMD_ERR_NO_MATCH; + vector_free(cmd_vector); return NULL; } else index = vector_active(vline) - 1;