[Libvirt-cim] [PATCH 2 of 2] (#4) add sdl frame buffer support

Eduardo Lima (Etrunko) eblima at linux.vnet.ibm.com
Thu Aug 11 17:57:09 UTC 2011


On 07/29/2011 04:05 AM, Wayne Xia wrote:

> diff -r 640ea61807cf -r f170cdc0acb5 src/Virt_VirtualSystemManagementService.c
> --- a/src/Virt_VirtualSystemManagementService.c	Mon Jul 25 19:39:08 2011 +0800
> +++ b/src/Virt_VirtualSystemManagementService.c	Tue Jul 26 17:02:51 2011 +0800
> @@ -1060,6 +1060,52 @@
>           return ret;
>   }
>
> +static int parse_sdl_address(const char *id,
> +                        char **display,
> +                        char **xauth)
> +{
> +        int ret;
> +        char *tmp_display = NULL;
> +        char *tmp_xauth = NULL;
> +
> +        CU_DEBUG("Entering parse_sdl_address, address is %s", id);
> +
> +        ret = sscanf(id, "%a[^:]:%as",&tmp_xauth,&tmp_display);
> +
> +        if (ret<= 0) {
> +                ret = sscanf(id, ":%as",&tmp_display);
> +                if (ret<= 0) {
> +                        if (STREQC(id, ":")) {
> +                                /* do nothing, it is empty */
> +                        }
> +                        else {
> +                                ret = 0;
> +                                goto out;
> +                        }
> +                }
> +        }
> +
> +        if (display) {
> +                if (tmp_display == NULL)
> +                    *display = NULL;
> +                else
> +                    *display = strdup(tmp_display);
> +        }
> +        if (xauth) {
> +                if (tmp_xauth == NULL)
> +                    *xauth = NULL;
> +                else
> +                    *xauth = strdup(tmp_xauth);
> +        }
> +        ret = 1;
> +
> + out:

This would leak tmp_display and tmp_xauth variables. According to 
sscanf(3), the 'a' character implies the resulting buffer should be freed.

            free(tmp_display);
	   free(tmp_xauth);

> +        CU_DEBUG("Exiting parse_sdl_address, display is %s, xauth is %s",
> +               *display, *xauth);
> +
> +        return ret;
> +}


ACK. Again, this could be fixed before push.

-- 
Eduardo de Barros Lima
Software Engineer, Open Virtualization
Linux Technology Center - IBM/Brazil
eblima at br.ibm.com




More information about the Libvirt-cim mailing list