qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] qga: Fix memory leak in split_list
@ 2022-10-18  4:46 Miaoqian Lin
  2022-10-18  6:31 ` Philippe Mathieu-Daudé
  2022-10-18  6:32 ` Marc-André Lureau
  0 siblings, 2 replies; 4+ messages in thread
From: Miaoqian Lin @ 2022-10-18  4:46 UTC (permalink / raw)
  To: Michael Roth, Konstantin Kostiuk, qemu-devel; +Cc: linmq006

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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-18  7:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-18  4:46 [PATCH] qga: Fix memory leak in split_list Miaoqian Lin
2022-10-18  6:31 ` Philippe Mathieu-Daudé
2022-10-18  6:32 ` Marc-André Lureau
2022-10-18  6:42   ` Miaoqian Lin

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).