qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] vl.c: fix memleaks with g_strdup+strtok


From: Quentin PEREZ
Subject: [Qemu-devel] [PATCH] vl.c: fix memleaks with g_strdup+strtok
Date: Wed, 24 Feb 2016 10:22:14 +0100 (CET)

>From cfd35648b6ab681891fe90b2813e63a4fdbe365f Mon Sep 17 00:00:00 2001
From: Quentin Perez <address@hidden>
Date: Wed, 24 Feb 2016 10:10:56 +0100
Subject: [PATCH] vl.c: fix memleaks with g_strdup+strtok

Signed-off-by: Quentin Perez <address@hidden>
---
 vl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/vl.c b/vl.c
index b87e292..9f6593a 100644
--- a/vl.c
+++ b/vl.c
@@ -1362,16 +1362,19 @@ static int add_semihosting_arg(void *opaque,
 static inline void semihosting_arg_fallback(const char *file, const char *cmd)
 {
     char *cmd_token;
+    char *dup_cmd;

     /* argv[0] */
     add_semihosting_arg(&semihosting, "arg", file, NULL);

     /* split -append and initialize argv[1..n] */
-    cmd_token = strtok(g_strdup(cmd), " ");
+    dup_cmd = g_strdup(cmd);
+    cmd_token = strtok(dup_cmd, " ");
     while (cmd_token) {
         add_semihosting_arg(&semihosting, "arg", cmd_token, NULL);
         cmd_token = strtok(NULL, " ");
     }
+    g_free(dup_cmd);
 }

 /* Now we still need this for compatibility with XEN. */
--
2.5.4 (Apple Git-61)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]