summaryrefslogtreecommitdiff
path: root/src/alloc.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-06-02 01:02:59 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-06-02 01:02:59 -0700
commit4008751468313f68b74ae3f1f1d3857e52f0062f (patch)
tree097dc626ab89c75e88fb70ba9a32f8f350f4c73c /src/alloc.c
parent7d5200893a8cc980744bb4c65355df5a936388bb (diff)
parentaf3c30cb283811135d9a1136fa5072e6922410a9 (diff)
downloademacs-4008751468313f68b74ae3f1f1d3857e52f0062f.tar.gz
Merge: Remove arbitrary limit of 2**31 entries in hash tables.
Fixes: debbugs:8771
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 e627af6c071..8fcc6f91df9 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -157,7 +157,7 @@ struct emacs_globals globals;
/* Number of bytes of consing done since the last gc. */
-int consing_since_gc;
+EMACS_INT consing_since_gc;
/* Similar minimum, computed from Vgc_cons_percentage. */
@@ -2788,6 +2788,11 @@ allocate_vectorlike (EMACS_INT len)
{
struct Lisp_Vector *p;
size_t nbytes;
+ int header_size = offsetof (struct Lisp_Vector, contents);
+ int word_size = sizeof p->contents[0];
+
+ if ((SIZE_MAX - header_size) / word_size < len)
+ memory_full ();
MALLOC_BLOCK_INPUT;
@@ -2801,8 +2806,7 @@ allocate_vectorlike (EMACS_INT len)
/* This gets triggered by code which I haven't bothered to fix. --Stef */
/* eassert (!handling_signal); */
- nbytes = (offsetof (struct Lisp_Vector, contents)
- + len * sizeof p->contents[0]);
+ nbytes = header_size + len * word_size;
p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE);
#ifdef DOUG_LEA_MALLOC