diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2009-11-19 01:40:22 +0000 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2009-11-19 01:40:22 +0000 |
commit | 87e32266f0fc8467bc8280c9b73b7c5ab9d5f951 (patch) | |
tree | ce23ebb18e3d66069782425bbf0ba344d90407f4 /src/insdel.c | |
parent | b2f0be0f79c0275c1677fee1a2ff62c42febc623 (diff) | |
download | emacs-87e32266f0fc8467bc8280c9b73b7c5ab9d5f951.tar.gz |
(make_gap_larger): Don't make as many assumptions about the
representation of Lisp integers.
Reported by MJ Chan <mjchan.inbox@gmail.com>.
Diffstat (limited to 'src/insdel.c')
-rw-r--r-- | src/insdel.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/insdel.c b/src/insdel.c index bdd450558bd..0faf3c07227 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -512,16 +512,16 @@ make_gap_larger (EMACS_INT nbytes_added) /* If we have to get more space, get enough to last a while. */ nbytes_added += 2000; - /* Don't allow a buffer size that won't fit in an int - even if it will fit in a Lisp integer. - That won't work because so many places use `int'. - - Make sure we don't introduce overflows in the calculation. */ - - if (Z_BYTE - BEG_BYTE + GAP_SIZE - >= (((EMACS_INT) 1 << (min (VALBITS, BITS_PER_INT) - 1)) - 1 - - nbytes_added)) - error ("Buffer exceeds maximum size"); + { EMACS_INT total_size = Z_BYTE - BEG_BYTE + GAP_SIZE + nbytes_added; + if (total_size < 0 + /* Don't allow a buffer size that won't fit in a Lisp integer. */ + || total_size != XINT (make_number (total_size)) + /* Don't allow a buffer size that won't fit in an int + even if it will fit in a Lisp integer. + That won't work because so many places still use `int'. */ + || total_size != (EMACS_INT) (int) total_size) + error ("Buffer exceeds maximum size"); + } enlarge_buffer_text (current_buffer, nbytes_added); |