[cairo-commit] src/cairo-win32-font.c

Adrian Johnson ajohnson at kemper.freedesktop.org
Sun Dec 21 16:42:33 PST 2008


 src/cairo-win32-font.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

New commits:
commit 6ce97907edfa8a7b09abfc090a9c03d235de2ada
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Mon Dec 22 11:09:27 2008 +1030

    win32-font: truncate instead of fail if toy font name too long
    
    http://lists.cairographics.org/archives/cairo/2008-December/016109.html

diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c
index be50c6c..e9abfda 100644
--- a/src/cairo-win32-font.c
+++ b/src/cairo-win32-font.c
@@ -534,12 +534,11 @@ _cairo_win32_font_face_create_for_toy (cairo_toy_font_face_t   *toy_face,
     if (status)
 	return status;
 
-    if (face_name_len > LF_FACESIZE - 1) {
-	free (face_name);
-	return _cairo_error (CAIRO_STATUS_INVALID_STRING);
-    }
+    if (face_name_len > LF_FACESIZE - 1)
+	face_name_len = LF_FACESIZE - 1;
 
-    memcpy (logfont.lfFaceName, face_name, sizeof (uint16_t) * (face_name_len + 1));
+    memcpy (logfont.lfFaceName, face_name, sizeof (uint16_t) * face_name_len);
+    logfont.lfFaceName[face_name_len] = 0;
     free (face_name);
 
     logfont.lfHeight = 0;	/* filled in later */


More information about the cairo-commit mailing list