Patchwork Fix tiny leak in qemu_opts_parse

login
register
mail settings
Submitter Jan Kiszka
Date April 29, 2010, 4:24 p.m.
Message ID <4BD9B2CB.7060107@siemens.com>
Download mbox | patch
Permalink /patch/51300/
State New
Headers show

Comments

Jan Kiszka - April 29, 2010, 4:24 p.m.
qemu_opts_create duplicates the id we pass in case it shall be stored in
the opts. So we do not need to dup it in qemu_opts_parse, leaking a few
bytes this way.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 qemu-option.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Anthony Liguori - May 3, 2010, 5:14 p.m.
On 04/29/2010 11:24 AM, Jan Kiszka wrote:
> qemu_opts_create duplicates the id we pass in case it shall be stored in
> the opts. So we do not need to dup it in qemu_opts_parse, leaking a few
> bytes this way.
>
> Signed-off-by: Jan Kiszka<jan.kiszka@siemens.com>
>    

Applied.  Thanks.

Regards,

Anthony Liguori
> ---
>   qemu-option.c |    4 ++--
>   1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/qemu-option.c b/qemu-option.c
> index 1ffc497..076dddf 100644
> --- a/qemu-option.c
> +++ b/qemu-option.c
> @@ -763,10 +763,10 @@ QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,
>
>       if (strncmp(params, "id=", 3) == 0) {
>           get_opt_value(value, sizeof(value), params+3);
> -        id = qemu_strdup(value);
> +        id = value;
>       } else if ((p = strstr(params, ",id=")) != NULL) {
>           get_opt_value(value, sizeof(value), p+4);
> -        id = qemu_strdup(value);
> +        id = value;
>       }
>       opts = qemu_opts_create(list, id, 1);
>       if (opts == NULL)
>
>
>
>

Patch

diff --git a/qemu-option.c b/qemu-option.c
index 1ffc497..076dddf 100644
--- a/qemu-option.c
+++ b/qemu-option.c
@@ -763,10 +763,10 @@  QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,
 
     if (strncmp(params, "id=", 3) == 0) {
         get_opt_value(value, sizeof(value), params+3);
-        id = qemu_strdup(value);
+        id = value;
     } else if ((p = strstr(params, ",id=")) != NULL) {
         get_opt_value(value, sizeof(value), p+4);
-        id = qemu_strdup(value);
+        id = value;
     }
     opts = qemu_opts_create(list, id, 1);
     if (opts == NULL)