Patchwork [v3,10/11] qapi: Fix unchecked strdup() by converting to g_strdup()

login
register
mail settings
Submitter Markus Armbruster
Date Jan. 22, 2013, 10:08 a.m.
Message ID <1358849286-24750-11-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/214507/
State New
Headers show

Comments

Markus Armbruster - Jan. 22, 2013, 10:08 a.m.
Note that we already free with g_free().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 qapi/qmp-registry.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Luiz Capitulino - Jan. 22, 2013, 4:38 p.m.
On Tue, 22 Jan 2013 11:08:05 +0100
Markus Armbruster <armbru@redhat.com> wrote:

> Note that we already free with g_free().
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>

> ---
>  qapi/qmp-registry.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/qapi/qmp-registry.c b/qapi/qmp-registry.c
> index 70cdbca..28bbbe8 100644
> --- a/qapi/qmp-registry.c
> +++ b/qapi/qmp-registry.c
> @@ -92,7 +92,7 @@ char **qmp_get_command_list(void)
>      list_head = list = g_malloc0(count * sizeof(char *));
>  
>      QTAILQ_FOREACH(cmd, &qmp_commands, node) {
> -        *list = strdup(cmd->name);
> +        *list = g_strdup(cmd->name);
>          list++;
>      }
>

Patch

diff --git a/qapi/qmp-registry.c b/qapi/qmp-registry.c
index 70cdbca..28bbbe8 100644
--- a/qapi/qmp-registry.c
+++ b/qapi/qmp-registry.c
@@ -92,7 +92,7 @@  char **qmp_get_command_list(void)
     list_head = list = g_malloc0(count * sizeof(char *));
 
     QTAILQ_FOREACH(cmd, &qmp_commands, node) {
-        *list = strdup(cmd->name);
+        *list = g_strdup(cmd->name);
         list++;
     }