[PATCH v2 2/2] qga/main: Don't mismatch g_strsplit/g_free in split_list()

pannengyuan@huawei.com posted 2 patches 6 years, 1 month ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Michael Roth <mdroth@linux.vnet.ibm.com>
[PATCH v2 2/2] qga/main: Don't mismatch g_strsplit/g_free in split_list()
Posted by pannengyuan@huawei.com 6 years, 1 month ago
From: Pan Nengyuan <pannengyuan@huawei.com>

fix a mismatch between g_strsplit and g_free

Reported-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
---
Changes v2 to v1:
- fix a mismatch in qga/main.c
---
 qga/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qga/main.c b/qga/main.c
index c35c2a2120..a72ae074f4 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -933,7 +933,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.21.0.windows.1



Re: [PATCH v2 2/2] qga/main: Don't mismatch g_strsplit/g_free in split_list()
Posted by Marc-André Lureau 6 years, 1 month ago
Hi

On Fri, Jan 10, 2020 at 1:18 PM <pannengyuan@huawei.com> wrote:
>
> From: Pan Nengyuan <pannengyuan@huawei.com>
>
> fix a mismatch between g_strsplit and g_free
>
> Reported-by: Laurent Vivier <laurent@vivier.eu>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>

NACK, the elements are added to the returned list.

> ---
> Changes v2 to v1:
> - fix a mismatch in qga/main.c
> ---
>  qga/main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/qga/main.c b/qga/main.c
> index c35c2a2120..a72ae074f4 100644
> --- a/qga/main.c
> +++ b/qga/main.c
> @@ -933,7 +933,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.21.0.windows.1
>
>
>


-- 
Marc-André Lureau

Re: [PATCH v2 2/2] qga/main: Don't mismatch g_strsplit/g_free in split_list()
Posted by Laurent Vivier 6 years, 1 month ago
Le 10/01/2020 à 10:41, Marc-André Lureau a écrit :
> Hi
> 
> On Fri, Jan 10, 2020 at 1:18 PM <pannengyuan@huawei.com> wrote:
>>
>> From: Pan Nengyuan <pannengyuan@huawei.com>
>>
>> fix a mismatch between g_strsplit and g_free
>>
>> Reported-by: Laurent Vivier <laurent@vivier.eu>
>> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> 
> NACK, the elements are added to the returned list.

It's my fault, sorry...

Laurent