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) {
}
} 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') {
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)