[PATCH 1/2] Xephyr: fix memory leak in XF86DRIOpenConnection

Jamey Sharp jamey at minilop.net
Thu Jun 24 11:22:02 PDT 2010


My reading of the code is that initializing busIdString to NULL is not
necessary--if XF86DRIOpenConnection returns TRUE then it has
initialized the pointer--but it's certainly both harmless and good
style.

Reviewed-by: Jamey Sharp <jamey at minilop.net>

On Thu, Jun 24, 2010 at 10:45 AM, Julien Cristau <jcristau at debian.org> wrote:
> The allocated bus id string was not being freed.
>
> Signed-off-by: Julien Cristau <jcristau at debian.org>
> ---
>  hw/kdrive/ephyr/ephyrdriext.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c
> index 4041bf5..ce584b0 100644
> --- a/hw/kdrive/ephyr/ephyrdriext.c
> +++ b/hw/kdrive/ephyr/ephyrdriext.c
> @@ -682,7 +682,7 @@ ProcXF86DRIOpenConnection (register ClientPtr client)
>  {
>     xXF86DRIOpenConnectionReply rep;
>     drm_handle_t                       hSAREA;
> -    char*                      busIdString;
> +    char*                      busIdString = NULL;
>     REQUEST(xXF86DRIOpenConnectionReq);
>     REQUEST_SIZE_MATCH(xXF86DRIOpenConnectionReq);
>
> @@ -716,6 +716,7 @@ ProcXF86DRIOpenConnection (register ClientPtr client)
>     WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), (char *)&rep);
>     if (rep.busIdStringLength)
>         WriteToClient(client, rep.busIdStringLength, busIdString);
> +    free(busIdString);
>     EPHYR_LOG ("leave\n") ;
>     return Success;
>  }
> --
> 1.7.1
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>


More information about the xorg-devel mailing list