[cairo-commit] cairo/src cairo-atsui-font.c,1.12,1.13

Tim Rowley commit at pdx.freedesktop.org
Tue Jun 28 11:52:44 PDT 2005


Committed by: tor

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv17249/src

Modified Files:
	cairo-atsui-font.c 
Log Message:
	* src/cairo-atsui-font.c (_cairo_atsui_font_text_to_glyphs):
	Prevent crash on empty string.


Index: cairo-atsui-font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-atsui-font.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cairo-atsui-font.c	21 Jun 2005 16:54:59 -0000	1.12
+++ cairo-atsui-font.c	28 Jun 2005 18:52:42 -0000	1.13
@@ -252,29 +252,32 @@
     ItemCount glyphCount, charCount;
     UniChar *theText;
 
-    err = ATSUCreateTextLayout(&textLayout);
-
-#if 1
+    // liberal estimate of size
     charCount = strlen(utf8);
 
+    if (charCount == 0) {
+       *glyphs = NULL;
+       *num_glyphs = 0;
+       return CAIRO_STATUS_SUCCESS;
+    }
+
     // Set the text in the text layout object, so we can measure it
     theText = (UniChar *) malloc(charCount * sizeof(UniChar));
 
+#if 1
     for (i = 0; i < charCount; i++) {
         theText[i] = utf8[i];
     }
 #endif
 
 #if 0
-    // Set the text in the text layout object, so we can measure it
-    charCount = strlen(utf8);
-    theText = (UniChar *) malloc(charCount * sizeof(UniChar));
-
     size_t inBytes = charCount, outBytes = charCount;
     iconv_t converter = iconv_open("UTF-8", "UTF-16");
     charCount = iconv(converter, utf8, &inBytes, theText, &outBytes);
 #endif
 
+    err = ATSUCreateTextLayout(&textLayout);
+
     err = ATSUSetTextPointerLocation(textLayout,
                                      theText, 0, charCount, charCount);
 




More information about the cairo-commit mailing list