/* * gcc `pkg-config cairo --cflags` uninitialized-blit.c \ * `pkg-config cairo --libs` */ #include #include int main(int argc, char* argv[]) { /* draw a stroke on an unbounded recording surface */ cairo_surface_t* rec = cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, 0); assert(cairo_surface_status(rec) == CAIRO_STATUS_SUCCESS); /* doesn't appear if recording surface isn't drawn to */ cairo_t* ctxr = cairo_create(rec); cairo_line_to(ctxr, 0.0, 1000.0); cairo_stroke(ctxr); cairo_destroy(ctxr); /* create an image surface, and fill it with the pattern of * the recording surface */ cairo_surface_t* img = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 200, 200); assert(cairo_surface_status(img) == CAIRO_STATUS_SUCCESS); cairo_t* ctx = cairo_create(img); cairo_set_source_surface(ctx, rec, 0.0, 0.0); cairo_rectangle(ctx, 0.0, 0.0, 200.0, 200.0); /* uninitialized read stems from the following fill. plain * cairo_paint has the same effect. */ cairo_fill(ctx); assert(cairo_surface_status(img) == CAIRO_STATUS_SUCCESS); assert(cairo_status(ctx) == CAIRO_STATUS_SUCCESS); cairo_destroy(ctx); cairo_surface_destroy(img); cairo_surface_destroy(rec); return 0; } #if 0 Conditional jump or move depends on uninitialised value(s) at 0x42B56FC: pixman_image_create_bits (pixman-bits-image.c:1296) by 0x4057886: _cairo_image_surface_create_with_pixman_format (cairo-image-surface.c:329) by 0x4057A48: cairo_image_surface_create (cairo-image-surface.c:379) by 0x405C5B9: _cairo_recording_surface_acquire_source_image (cairo-recording-surface.c:268) by 0x4078D58: _cairo_surface_acquire_source_image (cairo-surface.c:1443) by 0x4052F47: _pixman_image_for_pattern (cairo-image-surface.c:1493) by 0x4058531: _clip_and_composite_boxes (cairo-image-surface.c:2980) by 0x405950C: _cairo_image_surface_paint (cairo-image-surface.c:3295) by 0x407A185: _cairo_surface_paint (cairo-surface.c:2023) by 0x404DF66: _cairo_gstate_fill (cairo-gstate.c:1285) by 0x4043BB5: cairo_fill_preserve (cairo.c:2453) by 0x4043BE1: cairo_fill (cairo.c:2429) Uninitialised value was created by a heap allocation at 0x4025BD3: malloc (vg_replace_malloc.c:236) by 0x405C818: cairo_recording_surface_create (cairo-recording-surface.c:140) by 0x8048790: main (in /home/mike/Desktop/a.out) Conditional jump or move depends on uninitialised value(s) at 0x42B56FC: pixman_image_create_bits (pixman-bits-image.c:1296) by 0x4052F95: _pixman_image_for_pattern (cairo-image-surface.c:1517) by 0x4058531: _clip_and_composite_boxes (cairo-image-surface.c:2980) by 0x405950C: _cairo_image_surface_paint (cairo-image-surface.c:3295) by 0x407A185: _cairo_surface_paint (cairo-surface.c:2023) by 0x404DF66: _cairo_gstate_fill (cairo-gstate.c:1285) by 0x4043BB5: cairo_fill_preserve (cairo.c:2453) by 0x4043BE1: cairo_fill (cairo.c:2429) by 0x80488C8: main (in /home/mike/Desktop/a.out) Uninitialised value was created by a heap allocation at 0x4025BD3: malloc (vg_replace_malloc.c:236) by 0x405C818: cairo_recording_surface_create (cairo-recording-surface.c:140) by 0x8048790: main (in /home/mike/Desktop/a.out) Conditional jump or move depends on uninitialised value(s) at 0x42A82CE: analyze_extent (pixman.c:576) by 0x42A8BD2: pixman_image_composite32 (pixman.c:741) by 0x405862D: _clip_and_composite_boxes (cairo-image-surface.c:3002) by 0x405950C: _cairo_image_surface_paint (cairo-image-surface.c:3295) by 0x407A185: _cairo_surface_paint (cairo-surface.c:2023) by 0x404DF66: _cairo_gstate_fill (cairo-gstate.c:1285) by 0x4043BB5: cairo_fill_preserve (cairo.c:2453) by 0x4043BE1: cairo_fill (cairo.c:2429) by 0x80488C8: main (in /home/mike/Desktop/a.out) Uninitialised value was created by a heap allocation at 0x4025BD3: malloc (vg_replace_malloc.c:236) by 0x405C818: cairo_recording_surface_create (cairo-recording-surface.c:140) by 0x8048790: main (in /home/mike/Desktop/a.out) #endif