aboutsummaryrefslogtreecommitdiffstats
path: root/src/keymap.c
diff options
context:
space:
mode:
authorJoakim Verona2011-08-27 19:45:48 +0200
committerJoakim Verona2011-08-27 19:45:48 +0200
commit9fb7b0cab34a48a4c7b66abb6b8edc4ee20467b4 (patch)
treee94476d49f15747fcb9409d773702e88201855a4 /src/keymap.c
parentc7489583c30031c0ecfae9d20b20c149ca1935e9 (diff)
parentb75258b32810f3690442bddef2e10eef126d2d25 (diff)
downloademacs-9fb7b0cab34a48a4c7b66abb6b8edc4ee20467b4.tar.gz
emacs-9fb7b0cab34a48a4c7b66abb6b8edc4ee20467b4.zip
upstream
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/keymap.c b/src/keymap.c
index 3b0edbf4fb3..32b531daac4 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1399,7 +1399,7 @@ silly_event_symbol_error (Lisp_Object c)
1399 some systems, static gets macro-defined to be the empty string. 1399 some systems, static gets macro-defined to be the empty string.
1400 Ickypoo. */ 1400 Ickypoo. */
1401static Lisp_Object *cmm_modes = NULL, *cmm_maps = NULL; 1401static Lisp_Object *cmm_modes = NULL, *cmm_maps = NULL;
1402static int cmm_size = 0; 1402static ptrdiff_t cmm_size = 0;
1403 1403
1404/* Store a pointer to an array of the currently active minor modes in 1404/* Store a pointer to an array of the currently active minor modes in
1405 *modeptr, a pointer to an array of the keymaps of the currently 1405 *modeptr, a pointer to an array of the keymaps of the currently
@@ -1419,10 +1419,10 @@ static int cmm_size = 0;
1419 loop. Instead, we'll use realloc/malloc and silently truncate the 1419 loop. Instead, we'll use realloc/malloc and silently truncate the
1420 list, let the key sequence be read, and hope some other piece of 1420 list, let the key sequence be read, and hope some other piece of
1421 code signals the error. */ 1421 code signals the error. */
1422int 1422ptrdiff_t
1423current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr) 1423current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr)
1424{ 1424{
1425 int i = 0; 1425 ptrdiff_t i = 0;
1426 int list_number = 0; 1426 int list_number = 0;
1427 Lisp_Object alist, assoc, var, val; 1427 Lisp_Object alist, assoc, var, val;
1428 Lisp_Object emulation_alists; 1428 Lisp_Object emulation_alists;
@@ -1465,9 +1465,16 @@ current_minor_maps (Lisp_Object **modeptr, Lisp_Object **mapptr)
1465 1465
1466 if (i >= cmm_size) 1466 if (i >= cmm_size)
1467 { 1467 {
1468 int newsize, allocsize; 1468 ptrdiff_t newsize, allocsize;
1469 Lisp_Object *newmodes, *newmaps; 1469 Lisp_Object *newmodes, *newmaps;
1470 1470
1471 /* Check for size calculation overflow. Other code
1472 (e.g., read_key_sequence) adds 3 to the count
1473 later, so subtract 3 from the limit here. */
1474 if (min (PTRDIFF_MAX, SIZE_MAX) / (2 * sizeof *newmodes) - 3
1475 < cmm_size)
1476 break;
1477
1471 newsize = cmm_size == 0 ? 30 : cmm_size * 2; 1478 newsize = cmm_size == 0 ? 30 : cmm_size * 2;
1472 allocsize = newsize * sizeof *newmodes; 1479 allocsize = newsize * sizeof *newmodes;
1473 1480