From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYVeI-0006IS-8p for qemu-devel@nongnu.org; Wed, 24 Feb 2016 04:22:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYVeF-00051t-3J for qemu-devel@nongnu.org; Wed, 24 Feb 2016 04:22:22 -0500 Received: from mail.online.net ([62.210.16.11]:36682) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYVeE-00051D-Tm for qemu-devel@nongnu.org; Wed, 24 Feb 2016 04:22:19 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.online.net (Postfix) with ESMTP id 30EDF3E3914 for ; Wed, 24 Feb 2016 10:22:15 +0100 (CET) Received: from mail.online.net ([127.0.0.1]) by localhost (mail.online.net [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id NxafcL8yXUX2 for ; Wed, 24 Feb 2016 10:22:14 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.online.net (Postfix) with ESMTP id BC9353E37BF for ; Wed, 24 Feb 2016 10:22:14 +0100 (CET) Received: from mail.online.net ([127.0.0.1]) by localhost (mail.online.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 0cFJs-Zaukpx for ; Wed, 24 Feb 2016 10:22:14 +0100 (CET) Received: from mail.online.net (mail.online.net [62.210.16.11]) by mail.online.net (Postfix) with ESMTP id 9E2973E3914 for ; Wed, 24 Feb 2016 10:22:14 +0100 (CET) Date: Wed, 24 Feb 2016 10:22:14 +0100 (CET) From: Quentin PEREZ Message-ID: <921079541.7300112.1456305734547.JavaMail.zimbra@ocs.online.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] vl.c: fix memleaks with g_strdup+strtok List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org >>From cfd35648b6ab681891fe90b2813e63a4fdbe365f Mon Sep 17 00:00:00 2001 From: Quentin Perez Date: Wed, 24 Feb 2016 10:10:56 +0100 Subject: [PATCH] vl.c: fix memleaks with g_strdup+strtok Signed-off-by: Quentin Perez --- 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)