Subject: bug#12823: Invalid font name

From: Kenichi Handa <[email-masked]>
Date: Tue, 27 Nov 2012 23:26:27 +0900

For fixing this bug, I've just installed this change to
trunk (rev. 111019).  But, as the bug had caused crashing,
it may be better to apply the change to emacs-24.

---
Kenichi Handa
[email-masked]

=== modified file 'src/ChangeLog'
--- src/ChangeLog	2012-11-27 05:38:42 +0000
+++ src/ChangeLog	2012-11-27 13:40:38 +0000
@@ -1,3 +1,13 @@
+2012-11-18  Kenichi Handa  <[email-masked]>
+
+	* font.c (font_unparse_xlfd): Fix previous change.  Keep "const"
+	for the variable "f".
+
+2012-11-13  Kenichi Handa  <[email-masked]>
+
+	* font.c (font_unparse_xlfd): Exclude special characters from the
+	generating XLFD name.
+
 2012-11-27  Paul Eggert  <[email-masked]>
 
 	Assume POSIX 1003.1-1988 or later for grp.h, pwd.h.

=== modified file 'src/font.c'
--- src/font.c	2012-11-06 13:26:20 +0000
+++ src/font.c	2012-11-27 13:40:38 +0000
@@ -1234,8 +1234,21 @@
 	f[j] = "*";
       else
 	{
+	  int c, k, l;
+	  ptrdiff_t alloc;
+
 	  val = SYMBOL_NAME (val);
-	  f[j] = SSDATA (val);
+	  alloc = SBYTES (val) + 1;
+	  if (nbytes <= alloc)
+	    return -1;
+	  f[j] = p = alloca (alloc);
+	  /* Copy the name while excluding '-', '?', ',', and '"'.  */
+	  for (k = l = 0; k < alloc; k++)
+	    {
+	      c = SREF (val, k);
+	      if (c != '-' && c != '?' && c != ',' && c != '"')
+		p[l++] = c;
+	    }
 	}
     }