[cairo] Unicode error causing Cairo to crash.

Owen Taylor otaylor at redhat.com
Tue Apr 26 12:43:47 PDT 2005


On Tue, 2005-04-26 at 14:10 -0500, Hancock, Damion C wrote:
> I'm using cairo 0.1.23 snapshot, but wanted to try to move to cairo
> 0.4. 
> I'm trying to cache my own font metrics for each character.
> 
> The following code worked before but now causes a crash.  
> 
> #include <cairo.h>
> 
> #define NUM_CHARS 254
> 
> int main(int argc,char **argv) { 
>    unsigned char c[2]; 
>    cairo_t cc=cairo_create(); 
>    cairo_text_extents ce; 
>    int i;
> 
>    c[1]='\0'; 
>    for (c[0]=0;i=0; i < NUM_CHARS;c[0]++;i++)cairo_text_extents
> (cc,c,&ce); 
> }
> 
> If NUM_CHARS is 128 it works fine.  Should this cause I crash, even if
> some of 
> the characters are not displayable? 

cairo_text_extents() takes a UTF-8 string ... for anything > 256,
what you are putting into 'c' isn't valid UTF-8 character.

So, it shouldn't work. But it shouldn't crash either ... if it does,
file a bug.

Regards,
					Owen

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050426/58577a66/attachment.pgp


More information about the cairo mailing list