Range check octal-escaped characters
authorMichael Gran <spk121@yahoo.com>
Sat, 29 Aug 2009 14:14:49 +0000 (07:14 -0700)
committerMichael Gran <spk121@yahoo.com>
Sat, 29 Aug 2009 14:14:49 +0000 (07:14 -0700)
* libguile/read.c (scm_read_character): range check octal escapes

libguile/read.c

index a784f34..b2773cd 100644 (file)
@@ -848,12 +848,18 @@ scm_read_character (scm_t_wchar chr, SCM port)
     {
       /* Dirk:FIXME::  This type of character syntax is not R5RS
        * compliant.  Further, it should be verified that the constant
-       * does only consist of octal digits.  Finally, it should be
-       * checked whether the resulting fixnum is in the range of
-       * characters.  */
+       * does only consist of octal digits.  */
       SCM p = scm_string_to_number (charname, scm_from_uint (8));
       if (SCM_I_INUMP (p))
-       return SCM_MAKE_CHAR (SCM_I_INUM (p));
+        {
+          scm_t_wchar c = SCM_I_INUM (p);
+          if (SCM_IS_UNICODE_CHAR (c))
+            return SCM_MAKE_CHAR (c);
+          else
+            scm_i_input_error (FUNC_NAME, port, 
+                               "out-of-range octal character escape: ~a",
+                               scm_list_1 (charname));
+        }
     }
 
   /* The names of characters should never have non-Latin1