comparison src/insdel.c @ 106108:48d6337584da

(make_gap_larger): Don't make as many assumptions about the representation of Lisp integers. Reported by MJ Chan <mjchan.inbox@gmail.com>.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 19 Nov 2009 01:40:22 +0000
parents 21bdda3ded62
children f2cea199b0c4
comparison
equal deleted inserted replaced
106107:a387a3328e51 106108:48d6337584da
510 EMACS_INT old_gap_size; 510 EMACS_INT old_gap_size;
511 511
512 /* If we have to get more space, get enough to last a while. */ 512 /* If we have to get more space, get enough to last a while. */
513 nbytes_added += 2000; 513 nbytes_added += 2000;
514 514
515 /* Don't allow a buffer size that won't fit in an int 515 { EMACS_INT total_size = Z_BYTE - BEG_BYTE + GAP_SIZE + nbytes_added;
516 even if it will fit in a Lisp integer. 516 if (total_size < 0
517 That won't work because so many places use `int'. 517 /* Don't allow a buffer size that won't fit in a Lisp integer. */
518 518 || total_size != XINT (make_number (total_size))
519 Make sure we don't introduce overflows in the calculation. */ 519 /* Don't allow a buffer size that won't fit in an int
520 520 even if it will fit in a Lisp integer.
521 if (Z_BYTE - BEG_BYTE + GAP_SIZE 521 That won't work because so many places still use `int'. */
522 >= (((EMACS_INT) 1 << (min (VALBITS, BITS_PER_INT) - 1)) - 1 522 || total_size != (EMACS_INT) (int) total_size)
523 - nbytes_added)) 523 error ("Buffer exceeds maximum size");
524 error ("Buffer exceeds maximum size"); 524 }
525 525
526 enlarge_buffer_text (current_buffer, nbytes_added); 526 enlarge_buffer_text (current_buffer, nbytes_added);
527 527
528 /* Prevent quitting in move_gap. */ 528 /* Prevent quitting in move_gap. */
529 tem = Vinhibit_quit; 529 tem = Vinhibit_quit;