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

Bryce Harrington <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
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 <[email protected]>
> ---
>  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
> [email protected]
> http://lists.cairographics.org/mailman/listinfo/cairo
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.