From: Richard M. Stallman Date: Thu, 4 May 1995 22:16:18 +0000 (+0000) Subject: (make_gap): Don't allow buffer size that won't fit in int. X-Git-Tag: emacs-19.34~4167 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=94056516e269c6743ed0d3cdfe0242d61f788a44;p=emacs.git (make_gap): Don't allow buffer size that won't fit in int. --- diff --git a/src/insdel.c b/src/insdel.c index bf4a7e74f01..59c789a4e82 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -271,6 +271,14 @@ make_gap (increment) /* If we have to get more space, get enough to last a while. */ increment += 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'. */ + + if (VALBITS > INTBITS + && (Z - BEG + GAP_SIZE + increment) >= ((unsigned) 1 << (INTBITS - 1))) + error ("Buffer too big"); + BLOCK_INPUT; result = BUFFER_REALLOC (BEG_ADDR, (Z - BEG + GAP_SIZE + increment));