comparison src/insdel.c @ 42581:5f4c5a17743f

(make_gap_larger): Make sure buffer size does not overflow range of int.
author Andreas Schwab <schwab@suse.de>
date Sun, 06 Jan 2002 20:46:49 +0000
parents 79c7c91bc460
children e95258418289
comparison
equal deleted inserted replaced
42580:70727fae4ed2 42581:5f4c5a17743f
531 /* If we have to get more space, get enough to last a while. */ 531 /* If we have to get more space, get enough to last a while. */
532 nbytes_added += 2000; 532 nbytes_added += 2000;
533 533
534 /* Don't allow a buffer size that won't fit in an int 534 /* Don't allow a buffer size that won't fit in an int
535 even if it will fit in a Lisp integer. 535 even if it will fit in a Lisp integer.
536 That won't work because so many places use `int'. */ 536 That won't work because so many places use `int'.
537
538 Make sure we don't introduce overflows in the calculation. */
537 539
538 if (Z_BYTE - BEG_BYTE + GAP_SIZE + nbytes_added 540 if (Z_BYTE - BEG_BYTE + GAP_SIZE
539 >= MOST_POSITIVE_FIXNUM) 541 >= (((EMACS_INT) 1 << (min (VALBITS, BITS_PER_INT) - 1)) - 1
542 - nbytes_added))
540 error ("Buffer exceeds maximum size"); 543 error ("Buffer exceeds maximum size");
541 544
542 enlarge_buffer_text (current_buffer, nbytes_added); 545 enlarge_buffer_text (current_buffer, nbytes_added);
543 546
544 /* Prevent quitting in move_gap. */ 547 /* Prevent quitting in move_gap. */