qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Miaoqian Lin <linmq006@gmail.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>
Cc: Michael Roth <michael.roth@amd.com>,
	Konstantin Kostiuk <kkostiuk@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [PATCH] qga: Fix memory leak in split_list
Date: Tue, 18 Oct 2022 14:42:49 +0800	[thread overview]
Message-ID: <5d630010-57f8-fd11-04fc-6e52bdc15a80@gmail.com> (raw)
In-Reply-To: <CAJ+F1CLJFer=UoS7Udn0youfEgGAPG8xZJ9SokbGQm5CvXhugQ@mail.gmail.com>

Hi,

On 2022/10/18 14:32, Marc-André Lureau wrote:
> Hi
>
> On Tue, Oct 18, 2022 at 8:47 AM Miaoqian Lin <linmq006@gmail.com> wrote:
>
>     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);
>
>
> No, this is intentional. We are building a list of allocated strings, we shouldn't free those.
>  

I get it. Thanks for your response. Sorry for the mistake.


> thanks


      reply	other threads:[~2022-10-18  7:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=5d630010-57f8-fd11-04fc-6e52bdc15a80@gmail.com \
    --to=linmq006@gmail.com \
    --cc=kkostiuk@redhat.com \
    --cc=marcandre.lureau@gmail.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).