changeset 24583:0e5c5bd9b99d

(x_to_w32_font): Provide sufficient buffer to encode_coding to avoid carryover.
author Richard M. Stallman <rms@gnu.org>
date Wed, 07 Apr 1999 05:48:00 +0000
parents 1dc1bccbb4cc
children 244e710f3134
files src/w32fns.c
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/w32fns.c	Wed Apr 07 05:40:54 1999 +0000
+++ b/src/w32fns.c	Wed Apr 07 05:48:00 1999 +0000
@@ -5512,12 +5512,19 @@
 
       if (fields > 0 && name[0] != '*')
         {
+	  int bufsize;
+	  unsigned char *buf;
+
           setup_coding_system
             (Fcheck_coding_system (Vw32_system_coding_system), &coding);
+	  bufsize = encoding_buffer_size (&coding, strlen (name));
+	  buf = (unsigned char *) alloca (bufsize);
           coding.mode |= CODING_MODE_LAST_BLOCK;
-          encode_coding (&coding, name, lplogfont->lfFaceName,
-                         strlen (name), LF_FACESIZE-1);
-	  lplogfont->lfFaceName[coding.produced] = 0;
+          encode_coding (&coding, name, buf, strlen (name), bufsize);
+	  if (coding.produced >= LF_FACESIZE)
+	    coding.produced = LF_FACESIZE - 1;
+	  buf[coding.produced] = 0;
+	  strcpy (lplogfont->lfFaceName, buf);
 	}
       else
         {