mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-08 03:18:05 +02:00
Prevent crash on empty string.
This commit is contained in:
parent
f3b7d3dfd8
commit
e0982300ca
2 changed files with 15 additions and 7 deletions
|
|
@ -1,3 +1,8 @@
|
|||
2005-06-28 T Rowley <tim.rowley@gmail.com>
|
||||
|
||||
* src/cairo-atsui-font.c (_cairo_atsui_font_text_to_glyphs):
|
||||
Prevent crash on empty string.
|
||||
|
||||
2005-06-25 Keith Packard <keithp@keithp.com>
|
||||
|
||||
reviewed by: cworth
|
||||
|
|
|
|||
|
|
@ -252,29 +252,32 @@ _cairo_atsui_font_text_to_glyphs(void *abstract_font,
|
|||
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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue