changeset 17834:e154b943bbba

(non_ascii_char_to_string): Signal error if the argument C is an invalid character code. (Fconcat_chars): Use alloca instead of malloc.
author Kenichi Handa <handa@m17n.org>
date Fri, 16 May 1997 00:43:27 +0000
parents 59aa4a0772f6
children f36ffb6f1208
files src/charset.c
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/charset.c	Fri May 16 00:43:26 1997 +0000
+++ b/src/charset.c	Fri May 16 00:43:27 1997 +0000
@@ -96,7 +96,8 @@
    is not a composite character, the multi-byte form is set in WORKBUF
    and STR points WORKBUF.  The caller should allocate at least 4-byte
    area at WORKBUF in advance.  Returns the length of the multi-byte
-   form.
+   form.  If C is an invalid character to have a multi-byte form,
+   signal an error.
 
    Use macro `CHAR_STRING (C, WORKBUF, STR)' instead of calling this
    function directly if C can be an ASCII character.  */
@@ -119,12 +120,16 @@
 	}
       else
 	{
-	  *str = workbuf;
-	  return 0;
+	  error ("Invalid characer: %d", c);
 	}
     }
 
   SPLIT_NON_ASCII_CHAR (c, charset, c1, c2);
+  if (!charset
+      || ! CHARSET_DEFINED_P (charset)
+      || c1 >= 0 && c1 < 32
+      || c2 >= 0 && c2 < 32)
+    error ("Invalid characer: %d", c);
 
   *str = workbuf;
   *workbuf++ = CHARSET_LEADING_CODE_BASE (charset);
@@ -926,7 +931,7 @@
 {
   int i;
   unsigned char *buf
-    = (unsigned char *) malloc (MAX_LENGTH_OF_MULTI_BYTE_FORM * n);
+    = (unsigned char *) alloca (MAX_LENGTH_OF_MULTI_BYTE_FORM * n);
   unsigned char *p = buf;
   Lisp_Object val;
 
@@ -949,7 +954,6 @@
     }
 
   val = make_string (buf, p - buf);
-  free (buf);
   return val;
 }