[cairo] crasher

John McCutchan ttb at tentacle.dhs.org
Sat Mar 19 16:02:09 PST 2005


Yo,

This simple program crashes cairo. Am I doing something wrong or what?

https://bugs.freedesktop.org/show_bug.cgi?id=2776

#include <cairo.h>

int main (int argc, char **argv)
{
        int x, y, stride;
        cairo_t *cr;

        x = 400;
        y = 400;
        stride = x * 4;

        cr = cairo_create ();
        cairo_set_target_image (cr, (char *)malloc (sizeof(uint32_t) * x
* y), CAIRO_FORMAT_ARGB32, x, y, stride);

        while (1)       {
                        cairo_scale (cr, 400, 16);
                        cairo_set_line_width (cr, 0.04);
                        cairo_move_to (cr, 0.0, 0.0);
                        cairo_line_to (cr, 1.0, 0.0);
                        cairo_line_to (cr, 1.0, 1.0);
                        cairo_line_to (cr, 0.0, 1.0);

                        cairo_save (cr);
                                cairo_set_rgb_color (cr, 0.3725, 0.5254,
0.7019);
                                cairo_fill (cr);
                        cairo_restore (cr);

                        cairo_close_path (cr);
                        cairo_stroke (cr);
        }
}

backtrace,

Program received signal SIGSEGV, Segmentation fault.
cairo_font_destroy (font=0x0) at cairo_font.c:187
187         if (--(font->refcount) > 0)
(gdb) bt
#0  cairo_font_destroy (font=0x0) at cairo_font.c:187
#1  0x400b614e in _cairo_gstate_init_copy (gstate=0x9b400710,
other=0x804a018) at cairo_gstate.c:177
#2  0x400b63c8 in _cairo_gstate_clone (gstate=0x0) at cairo_gstate.c:245
#3  0x400b0e84 in *INT_cairo_save (cr=0x804a008) at cairo.c:176
#4  0x080488fe in main ()

-- 
John McCutchan <ttb at tentacle.dhs.org>



More information about the cairo mailing list