]> git.eshelyaron.com Git - emacs.git/commitdiff
(make_gap_larger): Don't make as many assumptions about the
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 19 Nov 2009 01:40:22 +0000 (01:40 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Thu, 19 Nov 2009 01:40:22 +0000 (01:40 +0000)
representation of Lisp integers.
Reported by MJ Chan <mjchan.inbox@gmail.com>.

src/ChangeLog
src/insdel.c

index 713bfe7d7d662d925aa4400b2af3143d079e07b8..474bc2e0e265dd31317d37dd46834adf18ed2afb 100644 (file)
@@ -1,3 +1,9 @@
+2009-11-19  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * insdel.c (make_gap_larger): Don't make as many assumptions about the
+       representation of Lisp integers.
+       Reported by MJ Chan <mjchan.inbox@gmail.com>.
+
 2009-11-17  Andreas Schwab  <schwab@linux-m68k.org>
 
        * lisp.h: Remove declaration of Ffont_get_system_font.
@@ -6,8 +12,8 @@
 
 2009-11-17  Jan Djärv  <jan.h.d@swipnet.se>
 
-       * xsettings.c (something_changedCB, Ffont_get_system_font): Check
-       use_system_font.
+       * xsettings.c (something_changedCB, Ffont_get_system_font):
+       Check use_system_font.
        (syms_of_xsettings): DEFVAR font-use-system-font.
 
 2009-11-17  Andreas Schwab  <schwab@linux-m68k.org>
 
 2009-11-17  Jan Djärv  <jan.h.d@swipnet.se>
 
-       * xftfont.c (xftfont_fix_match): Older versions of fontconfig does
+       * xftfont.c (xftfont_fix_match): Older versions of fontconfig do
        not have FC_LCD_*.  #define them if not there.
 
-       * xsettings.c (parse_xft_settings, apply_xft_settings): Ditto
+       * xsettings.c (parse_xft_settings, apply_xft_settings): Ditto.
 
        * xterm.h (struct x_display_info): Add atoms and Window for xsettings.
 
 
        * xfont.c (xfont_driver): Initialize all members.
 
-       * xfns.c (x_default_font_parameter): Try font from Ffont_get_system_font.
+       * xfns.c (x_default_font_parameter):
+       Try font from Ffont_get_system_font.
        Do not get font from x_default_parameter if we got one from
        Ffont_get_system_font.
-       (Fx_select_font): Get the defaut font name from :name of FRAME_FONT (f).
+       (Fx_select_font): Get the defaut font name from :name of FRAME_FONT(f).
 
        * w32font.c (w32font_driver): Initialize all members.
 
 
        * lisp.h: Declare syms_of_xsettings.
 
-       * keyboard.c (kbd_buffer_get_event, make_lispy_event): Handle 
-       CONFIG_CHANGED_EVENT.
+       * keyboard.c (kbd_buffer_get_event, make_lispy_event):
+       Handle CONFIG_CHANGED_EVENT.
 
        * ftfont.c (ftfont_filter_properties): New function.
 
        * frame.c (x_set_font): Remove unused variable lval.
 
-       * font.h (struct font_driver): filter_properties is new.
+       * font.h (struct font_driver): Add filter_properties.
 
        * font.c (font_put_extra): Don't return if val is nil, it means
        boolean option is off.
        (font_parse_fcname): Collect all extra properties in extra_props
        and call filter_properties for all drivers with extra_props and
        font as parameter.
-       (font_open_entity): Do not use cache, it does not pick up new fontconfig
-       settings like hinting.
+       (font_open_entity): Do not use cache, it does not pick up new
+       fontconfig settings like hinting.
        (font_load_for_lface): If spec had a name in it, store it in entity.
 
        * emacs.c (main): Call syms_of_xsettings
@@ -89,8 +96,7 @@
 
 2009-11-14  Andreas Schwab  <schwab@linux-m68k.org>
 
-       * Makefile.in: Ignore errors from mkdir when creating deps
-       directory.
+       * Makefile.in: Ignore errors from mkdir when creating deps directory.
 
 2009-11-14  Jan Djärv  <jan.h.d@swipnet.se>
 
index bdd450558bd46a454c1d6612fa836d2f69550518..0faf3c0722746d5e67d99805895d6142bc0ed9d2 100644 (file)
@@ -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);