diff options
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/alloc.c b/src/alloc.c index e627af6c071..8fcc6f91df9 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -157,7 +157,7 @@ struct emacs_globals globals; | |||
| 157 | 157 | ||
| 158 | /* Number of bytes of consing done since the last gc. */ | 158 | /* Number of bytes of consing done since the last gc. */ |
| 159 | 159 | ||
| 160 | int consing_since_gc; | 160 | EMACS_INT consing_since_gc; |
| 161 | 161 | ||
| 162 | /* Similar minimum, computed from Vgc_cons_percentage. */ | 162 | /* Similar minimum, computed from Vgc_cons_percentage. */ |
| 163 | 163 | ||
| @@ -2788,6 +2788,11 @@ allocate_vectorlike (EMACS_INT len) | |||
| 2788 | { | 2788 | { |
| 2789 | struct Lisp_Vector *p; | 2789 | struct Lisp_Vector *p; |
| 2790 | size_t nbytes; | 2790 | size_t nbytes; |
| 2791 | int header_size = offsetof (struct Lisp_Vector, contents); | ||
| 2792 | int word_size = sizeof p->contents[0]; | ||
| 2793 | |||
| 2794 | if ((SIZE_MAX - header_size) / word_size < len) | ||
| 2795 | memory_full (); | ||
| 2791 | 2796 | ||
| 2792 | MALLOC_BLOCK_INPUT; | 2797 | MALLOC_BLOCK_INPUT; |
| 2793 | 2798 | ||
| @@ -2801,8 +2806,7 @@ allocate_vectorlike (EMACS_INT len) | |||
| 2801 | /* This gets triggered by code which I haven't bothered to fix. --Stef */ | 2806 | /* This gets triggered by code which I haven't bothered to fix. --Stef */ |
| 2802 | /* eassert (!handling_signal); */ | 2807 | /* eassert (!handling_signal); */ |
| 2803 | 2808 | ||
| 2804 | nbytes = (offsetof (struct Lisp_Vector, contents) | 2809 | nbytes = header_size + len * word_size; |
| 2805 | + len * sizeof p->contents[0]); | ||
| 2806 | p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE); | 2810 | p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE); |
| 2807 | 2811 | ||
| 2808 | #ifdef DOUG_LEA_MALLOC | 2812 | #ifdef DOUG_LEA_MALLOC |