[cairo] [cairo-commit] 10 commits - configure.in src/cairo-arc.c src/cairo-pattern.c src/cairo-scaled-font.c src/cairo-scaled-font-private.h src/cairo-xlib-display.c src/cairo-xlib-private.h src/cairo-xlib-surface.c test/cairo-test.c test/degenerate-arc.c test/degenerate-arc-ps-ref.png test/degenerate-arc-ref.png test/.gitignore test/invalid-matrix.c test/Makefile.am

Behdad Esfahbod behdad at behdad.org
Thu May 8 08:53:34 PDT 2008


On Wed, 2008-05-07 at 00:22 -0700, Chris Wilson wrote:
> 
> +       to_free = glyphset_info->pending_free_glyphs;
> +       if (to_free != NULL &&
> +           to_free->glyph_count == ARRAY_LENGTH
> (to_free->glyph_indices))
> +       {
> +           status = _cairo_xlib_display_queue_work
> (font_private->display,
>                     (cairo_xlib_notify_func)
> _cairo_xlib_render_free_glyphs,
> -                   arg,
> +                   to_free,
>                     free);
> -           if (status) {
> -               /* XXX cannot propagate failure */
> -               free (arg);
> +           /* XXX cannot propagate failure */
> +           if (status)
> +               free (to_free);
> +
> +           to_free = glyphset_info->pending_free_glyphs = NULL;
> +       }
> +
> +       if (to_free == NULL) {
> +           to_free = malloc (sizeof
> (cairo_xlib_font_glyphset_free_glyphs_t));
> +           if (to_free == NULL) {
> +               _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
> +               return; /* XXX cannot propagate failure */
>             }

Here you can avoid freeing the to_free array and allocating it again...

Also this definitely doesn't look right:


> +           if (status)
> +               free (to_free);
> +
> +           to_free = glyphset_info->pending_free_glyphs = NULL;

Aren't you leaking to_free in case of success??

-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759



More information about the cairo mailing list