aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/coding.c b/src/coding.c
index 8b620af8695..84b774b4355 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -6867,6 +6867,11 @@ decode_eol (struct coding_system *coding)
6867} 6867}
6868 6868
6869 6869
6870/* MAX_LOOKUP's maximum value. MAX_LOOKUP is an int and so cannot
6871 exceed INT_MAX. Also, MAX_LOOKUP is multiplied by sizeof (int) for
6872 alloca, so it cannot exceed MAX_ALLOCA / sizeof (int). */
6873enum { MAX_LOOKUP_MAX = min (INT_MAX, MAX_ALLOCA / sizeof (int)) };
6874
6870/* Return a translation table (or list of them) from coding system 6875/* Return a translation table (or list of them) from coding system
6871 attribute vector ATTRS for encoding (if ENCODEP) or decoding (if 6876 attribute vector ATTRS for encoding (if ENCODEP) or decoding (if
6872 not ENCODEP). */ 6877 not ENCODEP). */
@@ -6919,7 +6924,7 @@ get_translation_table (Lisp_Object attrs, bool encodep, int *max_lookup)
6919 { 6924 {
6920 val = XCHAR_TABLE (translation_table)->extras[1]; 6925 val = XCHAR_TABLE (translation_table)->extras[1];
6921 if (NATNUMP (val) && *max_lookup < XFASTINT (val)) 6926 if (NATNUMP (val) && *max_lookup < XFASTINT (val))
6922 *max_lookup = XFASTINT (val); 6927 *max_lookup = min (XFASTINT (val), MAX_LOOKUP_MAX);
6923 } 6928 }
6924 else if (CONSP (translation_table)) 6929 else if (CONSP (translation_table))
6925 { 6930 {
@@ -6931,7 +6936,7 @@ get_translation_table (Lisp_Object attrs, bool encodep, int *max_lookup)
6931 { 6936 {
6932 Lisp_Object tailval = XCHAR_TABLE (XCAR (tail))->extras[1]; 6937 Lisp_Object tailval = XCHAR_TABLE (XCAR (tail))->extras[1];
6933 if (NATNUMP (tailval) && *max_lookup < XFASTINT (tailval)) 6938 if (NATNUMP (tailval) && *max_lookup < XFASTINT (tailval))
6934 *max_lookup = XFASTINT (tailval); 6939 *max_lookup = min (XFASTINT (tailval), MAX_LOOKUP_MAX);
6935 } 6940 }
6936 } 6941 }
6937 } 6942 }
@@ -10011,7 +10016,8 @@ make_subsidiaries (Lisp_Object base)
10011{ 10016{
10012 Lisp_Object subsidiaries; 10017 Lisp_Object subsidiaries;
10013 ptrdiff_t base_name_len = SBYTES (SYMBOL_NAME (base)); 10018 ptrdiff_t base_name_len = SBYTES (SYMBOL_NAME (base));
10014 char *buf = alloca (base_name_len + 6); 10019 USE_SAFE_ALLOCA;
10020 char *buf = SAFE_ALLOCA (base_name_len + 6);
10015 int i; 10021 int i;
10016 10022
10017 memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len); 10023 memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len);
@@ -10021,6 +10027,7 @@ make_subsidiaries (Lisp_Object base)
10021 strcpy (buf + base_name_len, suffixes[i]); 10027 strcpy (buf + base_name_len, suffixes[i]);
10022 ASET (subsidiaries, i, intern (buf)); 10028 ASET (subsidiaries, i, intern (buf));
10023 } 10029 }
10030 SAFE_FREE ();
10024 return subsidiaries; 10031 return subsidiaries;
10025} 10032}
10026 10033