diff options
| author | Paul Eggert | 2011-06-08 10:48:26 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-06-08 10:48:26 -0700 |
| commit | 86f61a158aea8dead5a0836a919a0ce501d3bcf7 (patch) | |
| tree | 8944f7ffdc459c2b7516df2ecad66d68a127c921 /src/alloc.c | |
| parent | c78baabfc2e52a99d85d2e28f8f67d75e4d93778 (diff) | |
| download | emacs-86f61a158aea8dead5a0836a919a0ce501d3bcf7.tar.gz emacs-86f61a158aea8dead5a0836a919a0ce501d3bcf7.zip | |
* alloc.c (allocate_vectorlike): Check for ptrdiff_t overflow.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/alloc.c b/src/alloc.c index 88542e86c48..2dbaef9b00b 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -2802,10 +2802,11 @@ allocate_vectorlike (EMACS_INT len) | |||
| 2802 | { | 2802 | { |
| 2803 | struct Lisp_Vector *p; | 2803 | struct Lisp_Vector *p; |
| 2804 | size_t nbytes; | 2804 | size_t nbytes; |
| 2805 | ptrdiff_t nbytes_max = min (PTRDIFF_MAX, SIZE_MAX); | ||
| 2805 | int header_size = offsetof (struct Lisp_Vector, contents); | 2806 | int header_size = offsetof (struct Lisp_Vector, contents); |
| 2806 | int word_size = sizeof p->contents[0]; | 2807 | int word_size = sizeof p->contents[0]; |
| 2807 | 2808 | ||
| 2808 | if ((SIZE_MAX - header_size) / word_size < len) | 2809 | if ((nbytes_max - header_size) / word_size < len) |
| 2809 | memory_full (SIZE_MAX); | 2810 | memory_full (SIZE_MAX); |
| 2810 | 2811 | ||
| 2811 | MALLOC_BLOCK_INPUT; | 2812 | MALLOC_BLOCK_INPUT; |