[PATCH] DRI2: Fix memory leak when a screen is not DRI2 capable.

Ian Romanick idr at freedesktop.org
Thu Oct 14 18:03:49 PDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kusanagi Kouichi wrote:
> Signed-off-by: Kusanagi Kouichi <slash at ac.auone-net.jp>

Looks good.

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

> ---
>  glx/glxdri2.c |   13 +++++++------
>  1 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/glx/glxdri2.c b/glx/glxdri2.c
> index c2305ad..6dc25ee 100644
> --- a/glx/glxdri2.c
> +++ b/glx/glxdri2.c
> @@ -701,6 +701,7 @@ initializeExtensions(__GLXDRIscreen *screen)
>  static __GLXscreen *
>  __glXDRIscreenProbe(ScreenPtr pScreen)
>  {
> +    int fd;
>      const char *driverName, *deviceName;
>      __GLXDRIscreen *screen;
>      char filename[128];
> @@ -710,23 +711,23 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
>      const __DRIconfig **driConfigs;
>      int i;
>  
> -    screen = calloc(1, sizeof *screen);
> -    if (screen == NULL)
> -	return NULL;
> -
>      if (!xf86LoaderCheckSymbol("DRI2Connect") ||
> -	!DRI2Connect(pScreen, DRI2DriverDRI,
> -		     &screen->fd, &driverName, &deviceName)) {
> +	!DRI2Connect(pScreen, DRI2DriverDRI, &fd, &driverName, &deviceName)) {
>  	LogMessage(X_INFO,
>  		   "AIGLX: Screen %d is not DRI2 capable\n", pScreen->myNum);
>  	return NULL;
>      }
>  
> +    screen = calloc(1, sizeof *screen);
> +    if (screen == NULL)
> +	return NULL;
> +
>      screen->base.destroy        = __glXDRIscreenDestroy;
>      screen->base.createContext  = __glXDRIscreenCreateContext;
>      screen->base.createDrawable = __glXDRIscreenCreateDrawable;
>      screen->base.swapInterval   = __glXDRIdrawableSwapInterval;
>      screen->base.pScreen       = pScreen;
> +    screen->fd = fd;
>  
>      __glXInitExtensionEnableBits(screen->glx_enable_bits);
>  

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAky3qHMACgkQX1gOwKyEAw8V2gCfRQin0XksYrCvJhc6TgwlKP3v
fY4An1t5mJEbcL3ebi8ehY/QtBdJmBt0
=0Pr7
-----END PGP SIGNATURE-----


More information about the xorg-devel mailing list