[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 01/23] monitor: Fix leakage during completion proces
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 01/23] monitor: Fix leakage during completion processing |
Date: |
Thu, 1 Jul 2010 16:21:29 -0300 |
From: Jan Kiszka <address@hidden>
Given too many arguments or an invalid command, we were leaking the
duplicated argument strings.
Signed-off-by: Jan Kiszka <address@hidden>
Signed-off-by: Luiz Capitulino <address@hidden>
---
monitor.c | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/monitor.c b/monitor.c
index 170b269..42ae154 100644
--- a/monitor.c
+++ b/monitor.c
@@ -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)
--
1.7.2.rc0
- [Qemu-devel] [PATCH 00/23][PULL]: QMP/Monitor queue, Luiz Capitulino, 2010/07/01
- [Qemu-devel] [PATCH 01/23] monitor: Fix leakage during completion processing,
Luiz Capitulino <=
- [Qemu-devel] [PATCH 02/23] monitor: Fix command completion vs. boolean switches, Luiz Capitulino, 2010/07/01
- [Qemu-devel] [PATCH 03/23] monitor: Establish cmd flags and convert the async tag, Luiz Capitulino, 2010/07/01
- [Qemu-devel] [PATCH 04/23] QMP: Teach basic capability negotiation to python example, Luiz Capitulino, 2010/07/01
- [Qemu-devel] [PATCH 05/23] QMP: Fix python helper /wrt long return strings, Luiz Capitulino, 2010/07/01
- [Qemu-devel] [PATCH 06/23] net: delete QemuOpts when net_client_init() fails., Luiz Capitulino, 2010/07/01
- [Qemu-devel] [PATCH 07/23] QMP: Fix error reporting in the async API, Luiz Capitulino, 2010/07/01
- [Qemu-devel] [PATCH 09/23] QDict: Rename 'err_value', Luiz Capitulino, 2010/07/01
- [Qemu-devel] [PATCH 08/23] QError: Enhance QERR_DEVICE_NOT_ACTIVE's user desc, Luiz Capitulino, 2010/07/01
- [Qemu-devel] [PATCH 11/23] QDict: Introduce functions to retrieve QDictEntry values, Luiz Capitulino, 2010/07/01
- [Qemu-devel] [PATCH 10/23] QDict: Small terminology change, Luiz Capitulino, 2010/07/01