qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Miaoqian Lin <linmq006@gmail.com>
To: Michael Roth <michael.roth@amd.com>,
	Konstantin Kostiuk <kkostiuk@redhat.com>,
	qemu-devel@nongnu.org
Cc: linmq006@gmail.com
Subject: [PATCH] qga: Fix memory leak in split_list
Date: Tue, 18 Oct 2022 08:46:45 +0400	[thread overview]
Message-ID: <20221018044645.863859-1-linmq006@gmail.com> (raw)

We should use g_strfreev to free the memory allocated by g_strsplit().
Use g_free() will cause a memory leak.

Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 qga/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qga/main.c b/qga/main.c
index 5a9d8252e075..04902076b25d 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -934,7 +934,7 @@ static GList *split_list(const gchar *str, const gchar *delim)
     for (i = 0; strv[i]; i++) {
         list = g_list_prepend(list, strv[i]);
     }
-    g_free(strv);
+    g_strfreev(strv);
 
     return list;
 }
-- 
2.25.1



             reply	other threads:[~2022-10-18  4:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18  4:46 Miaoqian Lin [this message]
2022-10-18  6:31 ` [PATCH] qga: Fix memory leak in split_list Philippe Mathieu-Daudé
2022-10-18  6:32 ` Marc-André Lureau
2022-10-18  6:42   ` Miaoqian Lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221018044645.863859-1-linmq006@gmail.com \
    --to=linmq006@gmail.com \
    --cc=kkostiuk@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).