changeset 94981:e01e37b8203e

(Fnew_fontset): Call font_unparse_xlfd with 256-byte buffer. Check the return value of it.
author Kenichi Handa <handa@m17n.org>
date Thu, 15 May 2008 00:41:26 +0000
parents 51e9d65c90fc
children 4acb1f365ac4
files src/fontset.c
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/fontset.c	Thu May 15 00:26:27 2008 +0000
+++ b/src/fontset.c	Thu May 15 00:41:26 2008 +0000
@@ -1557,7 +1557,7 @@
     {
       Lisp_Object font_spec = Ffont_spec (0, NULL);
       Lisp_Object short_name;
-      char *xlfd;
+      char xlfd[256];
       int len;
 
       if (font_parse_xlfd (SDATA (name), font_spec) < 0)
@@ -1570,8 +1570,9 @@
 				    Vfontset_alias_alist);
       ASET (font_spec, FONT_REGISTRY_INDEX, Qiso8859_1);
       fontset = make_fontset (Qnil, name, Qnil);
-      xlfd = alloca (SBYTES (name) + 1);
-      len = font_unparse_xlfd (font_spec, 0, xlfd, SBYTES (name) + 1);
+      len = font_unparse_xlfd (font_spec, 0, xlfd, 256);
+      if (len < 0)
+	error ("Invalid fontset name (perhaps too long): %s", SDATA (name));
       FONTSET_ASCII (fontset) = make_unibyte_string (xlfd, len);
     }
   else