aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 6b901d5465e..4449dd989de 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
160int consing_since_gc; 160EMACS_INT consing_since_gc;
161 161
162/* Similar minimum, computed from Vgc_cons_percentage. */ 162/* Similar minimum, computed from Vgc_cons_percentage. */
163 163
@@ -2789,6 +2789,11 @@ allocate_vectorlike (EMACS_INT len)
2789{ 2789{
2790 struct Lisp_Vector *p; 2790 struct Lisp_Vector *p;
2791 size_t nbytes; 2791 size_t nbytes;
2792 int header_size = offsetof (struct Lisp_Vector, contents);
2793 int word_size = sizeof p->contents[0];
2794
2795 if ((SIZE_MAX - header_size) / word_size < len)
2796 memory_full ();
2792 2797
2793 MALLOC_BLOCK_INPUT; 2798 MALLOC_BLOCK_INPUT;
2794 2799
@@ -2802,8 +2807,7 @@ allocate_vectorlike (EMACS_INT len)
2802 /* This gets triggered by code which I haven't bothered to fix. --Stef */ 2807 /* This gets triggered by code which I haven't bothered to fix. --Stef */
2803 /* eassert (!handling_signal); */ 2808 /* eassert (!handling_signal); */
2804 2809
2805 nbytes = (offsetof (struct Lisp_Vector, contents) 2810 nbytes = header_size + len * word_size;
2806 + len * sizeof p->contents[0]);
2807 p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE); 2811 p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE);
2808 2812
2809#ifdef DOUG_LEA_MALLOC 2813#ifdef DOUG_LEA_MALLOC