diff options
| author | Paul Eggert | 2011-06-02 01:25:28 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-06-02 01:25:28 -0700 |
| commit | 275a5dd65098a2d6fcc14c21f805fc8d5e4479ee (patch) | |
| tree | a03e79b0a7c066940ed02cd11927c7fd4080f092 /src/alloc.c | |
| parent | 97f4ea979720e535ade3fe0055fb710e18fb7b5d (diff) | |
| parent | f797625a8ca7bc973b6943c6fce97f1e479a283d (diff) | |
| download | emacs-275a5dd65098a2d6fcc14c21f805fc8d5e4479ee.tar.gz emacs-275a5dd65098a2d6fcc14c21f805fc8d5e4479ee.zip | |
Merge from trunk.
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 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 | ||
| 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 | ||
| @@ -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 |