[cairo] Potential issue

Alexandre Bique bique.alexandre at gmail.com
Mon Aug 28 14:38:43 UTC 2017


Hi guys,

>From this chunk of code (1.14.8)

static cairo_status_t
_cairo_default_context_set_scaled_font (void *abstract_cr,
                                        cairo_scaled_font_t *scaled_font)
{
    cairo_default_context_t *cr = abstract_cr;
    cairo_bool_t was_previous;
    cairo_status_t status;

    if (scaled_font == cr->gstate->scaled_font)
        return CAIRO_STATUS_SUCCESS;

    was_previous = scaled_font == cr->gstate->previous_scaled_font;

    status = _cairo_gstate_set_font_face (cr->gstate, scaled_font->font_face);
    if (unlikely (status))
        return status;

    status = _cairo_gstate_set_font_matrix (cr->gstate,
&scaled_font->font_matrix);
    if (unlikely (status))
        return status;

    _cairo_gstate_set_font_options (cr->gstate, &scaled_font->options);

    if (was_previous)
        cr->gstate->scaled_font = cairo_scaled_font_reference (scaled_font);

    return CAIRO_STATUS_SUCCESS;
}


It seems that if you do cairo_set_scaled_font(cairo_get_scaled_font())
you would trigger a memory leak right?

Regards,
-- 
Alexandre Bique


More information about the cairo mailing list