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
This commit is contained in:
Holger Hans Peter Freyther 2013-07-03 09:32:37 +02:00
parent cd252e3565
commit 047213b01e
1 changed files with 3 additions and 0 deletions

View File

@ -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;