Skip to contentSkip to conversation

Fix tiny leak in qemu_opts_parse

PATCH Applied Jan Kiszka 2 participants 2 messages Apr 29, 2010 – May 3, 2010

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 Fix tiny leak in qemu_opts_parse

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.

---
 qemu-option.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
qemu-option.c +2 -2
index 1ffc497..076dddf 100644
@@ -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)
#1 lore raw
Quoted 6 lines · Jan Kiszka

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.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 25 lines
---
  qemu-option.c |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
qemu-option.c +2 -2
index 1ffc497..076dddf 100644
@@ -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)