[cairo] static array allocation caused a segfault

Vladimir Vukicevic vladimir at pobox.com
Mon Nov 12 16:49:46 PST 2007


On Nov 12, 2007, at 12:02 PM, Pete wrote:

> qiuhqing <qiuhqing <at> gmail.com> writes:
>>    double rgb[805*805*3];
>>    CAIRO_FORMAT_ARGB32,
>
>
> Also be aware that ARGB32 should be 805 * 805 * 4. Your static array  
> is too
> small, even if it works directly on the stack like this.

While we're at it, it should be 805*805 of uint32_t, not of double.  A  
memory chunk of 805*805*3 doubles is plenty big for an 805x805 ARGB32  
image, but I hope you're not going to try accessing it directly :)

But given that you're using cairo_image_surface_create, and not  
create_for_data, I'm guessing that you want to read data to or from  
the double array, and not use it directly as a cairo surface.  Just  
heap allocate the data and you should be fine.

     - Vlad



More information about the cairo mailing list