[cairo] [PATCH] xlib: Fix deferencing of uninitialised 'display'

Bryce Harrington bryce at osg.samsung.com
Mon Jul 6 14:15:13 PDT 2015


On Tue, Jun 30, 2015 at 03:23:29PM +0530, Arpit Jain wrote:
>     Initialising 'display' to NULL and checking before deferencing during display->base.
>     This patch will check the deferencing of uninitialised 'display' in case,
>     _cairo_xlib_display_acquire does not return CAIRO_STATUS_SUCCESS.
> 
>     Fixes:  https://bugs.freedesktop.org/show_bug.cgi?id=87893

Hi Arpit, thanks for the bugfix!
 
> Signed-off-by: Arpit Jain <jain.arpit at samsung.com>
> ---
>  src/cairo-xlib-render-compositor.c |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/cairo-xlib-render-compositor.c b/src/cairo-xlib-render-compositor.c
> index 8a1ec7b..055780d 100644
> --- a/src/cairo-xlib-render-compositor.c
> +++ b/src/cairo-xlib-render-compositor.c
> @@ -958,7 +958,7 @@ _cairo_xlib_font_fini (cairo_scaled_font_private_t *abstract_private,
>  {
>      cairo_xlib_font_t *priv = (cairo_xlib_font_t *) abstract_private;
>      cairo_status_t status;
> -    cairo_xlib_display_t *display;
> +    cairo_xlib_display_t *display = NULL;
>      int i;
>  
>      cairo_list_del (&priv->base.link);
> @@ -978,7 +978,11 @@ _cairo_xlib_font_fini (cairo_scaled_font_private_t *abstract_private,
>  
>      cairo_device_release (&display->base);
>  BAIL:
> -    cairo_device_destroy (&display->base);
> +    if(display)
> +	cairo_device_destroy (&display->base);
> +    else
> +	cairo_device_destroy (priv->device);
> +	
>      free (priv);

Maybe the device destruction could be done prior to jumping to BAIL, and
thus avoid the if clause here, but with the clause it does make it a bit
more obvious what's going on.  So, looks good as is.

Thanks, pushed:
To ssh://git.cairographics.org/git/cairo
   06a2696..f6843d5  master -> master

>  }
>  
> -- 
> 1.7.9.5
> 
> 
> -- 
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo


More information about the cairo mailing list