]> git.puffer.fish Git - mirror/frr.git/commitdiff
vtysh: properly fix memory leak 1361/head
authorRenato Westphal <renato@opensourcerouting.org>
Wed, 25 Oct 2017 09:43:32 +0000 (07:43 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Wed, 25 Oct 2017 09:56:42 +0000 (07:56 -0200)
Commit 44f12f20 fixed the memory leak in the wrong way and introduced a
"uninitialized variable" warning.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
vtysh/vtysh.c

index 92c6f64e1c4d2faed2ac9b7aab6aa361ea564cdc..72a15f24ddb16c1147d147f710e83dcf6cf0820c 100644 (file)
@@ -807,24 +807,26 @@ static int vtysh_rl_describe(void)
 
        fprintf(stdout, "\n");
 
+       describe = cmd_describe_command(vline, vty, &ret);
+
        /* Ambiguous and no match error. */
        switch (ret) {
        case CMD_ERR_AMBIGUOUS:
                cmd_free_strvec(vline);
+               vector_free(describe);
                fprintf(stdout, "%% Ambiguous command.\n");
                rl_on_new_line();
                return 0;
                break;
        case CMD_ERR_NO_MATCH:
                cmd_free_strvec(vline);
+               vector_free(describe);
                fprintf(stdout, "%% There is no matched command.\n");
                rl_on_new_line();
                return 0;
                break;
        }
 
-       describe = cmd_describe_command(vline, vty, &ret);
-
        /* Get width of command string. */
        width = 0;
        for (i = 0; i < vector_active(describe); i++)