diff mbox

[v3,11/11] qemu-ga: Fix unchecked strdup() by converting to g_strdup()

Message ID 1358849286-24750-12-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster Jan. 22, 2013, 10:08 a.m. UTC
I figure it's freed somewhere deep down in QAPI, with g_free().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 qga/commands.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Luiz Capitulino Jan. 22, 2013, 4:54 p.m. UTC | #1
On Tue, 22 Jan 2013 11:08:06 +0100
Markus Armbruster <armbru@redhat.com> wrote:

> I figure it's freed somewhere deep down in QAPI, with g_free().

It is, by qapi_dealloc_type_str().

> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>

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

> ---
>  qga/commands.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/qga/commands.c b/qga/commands.c
> index 7ffb35e..528b082 100644
> --- a/qga/commands.c
> +++ b/qga/commands.c
> @@ -61,7 +61,7 @@ struct GuestAgentInfo *qmp_guest_info(Error **err)
>  
>      while (*cmd_list) {
>          cmd_info = g_malloc0(sizeof(GuestAgentCommandInfo));
> -        cmd_info->name = strdup(*cmd_list);
> +        cmd_info->name = g_strdup(*cmd_list);
>          cmd_info->enabled = qmp_command_is_enabled(cmd_info->name);
>  
>          cmd_info_list = g_malloc0(sizeof(GuestAgentCommandInfoList));
Stefan Hajnoczi Jan. 23, 2013, 7:46 a.m. UTC | #2
On Tue, Jan 22, 2013 at 02:54:21PM -0200, Luiz Capitulino wrote:
> On Tue, 22 Jan 2013 11:08:06 +0100
> Markus Armbruster <armbru@redhat.com> wrote:
> 
> > I figure it's freed somewhere deep down in QAPI, with g_free().
> 
> It is, by qapi_dealloc_type_str().
> 
> > Signed-off-by: Markus Armbruster <armbru@redhat.com>
> > Reviewed-by: Eric Blake <eblake@redhat.com>
> 
> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>

Thanks for the reviews, Luiz.  Your Reviewed-by: has been added to the
2 commits.

Stefan
diff mbox

Patch

diff --git a/qga/commands.c b/qga/commands.c
index 7ffb35e..528b082 100644
--- a/qga/commands.c
+++ b/qga/commands.c
@@ -61,7 +61,7 @@  struct GuestAgentInfo *qmp_guest_info(Error **err)
 
     while (*cmd_list) {
         cmd_info = g_malloc0(sizeof(GuestAgentCommandInfo));
-        cmd_info->name = strdup(*cmd_list);
+        cmd_info->name = g_strdup(*cmd_list);
         cmd_info->enabled = qmp_command_is_enabled(cmd_info->name);
 
         cmd_info_list = g_malloc0(sizeof(GuestAgentCommandInfoList));