diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2010-06-16 00:38:33 +0200 |
---|---|---|
committer | Luiz Capitulino <lcapitulino@redhat.com> | 2010-07-01 13:58:38 -0300 |
commit | 03a63484a6978f68caff087bbaabcd1d383563af (patch) | |
tree | 8e0c4a2f120a585bd10e8421679cb279b770b04a /monitor.c | |
parent | 449041d4db1f82f281fe097e832f07cd9ee1e864 (diff) |
monitor: Fix leakage during completion processing
Given too many arguments or an invalid command, we were leaking the
duplicated argument strings.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -3882,8 +3882,9 @@ static void monitor_find_completion(const char *cmdline) next arg */ len = strlen(cmdline); if (len > 0 && qemu_isspace(cmdline[len - 1])) { - if (nb_args >= MAX_ARGS) - return; + if (nb_args >= MAX_ARGS) { + goto cleanup; + } args[nb_args++] = qemu_strdup(""); } if (nb_args <= 1) { @@ -3898,12 +3899,15 @@ static void monitor_find_completion(const char *cmdline) } } else { /* find the command */ - for(cmd = mon_cmds; cmd->name != NULL; cmd++) { - if (compare_cmd(args[0], cmd->name)) - goto found; + for (cmd = mon_cmds; cmd->name != NULL; cmd++) { + if (compare_cmd(args[0], cmd->name)) { + break; + } } - return; - found: + if (!cmd->name) { + goto cleanup; + } + ptype = next_arg_type(cmd->args_type); for(i = 0; i < nb_args - 2; i++) { if (*ptype != '\0') { @@ -3953,8 +3957,11 @@ static void monitor_find_completion(const char *cmdline) break; } } - for(i = 0; i < nb_args; i++) + +cleanup: + for (i = 0; i < nb_args; i++) { qemu_free(args[i]); + } } static int monitor_can_read(void *opaque) |