diff options
| author | Paul Eggert | 2011-08-04 19:15:35 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-08-04 19:15:35 -0700 |
| commit | 0065d05491ce5981ea20896bb26d21dcd31e6769 (patch) | |
| tree | 13240167319d4a99ab5eacae4a883258eb2d28de /src/xterm.c | |
| parent | 18ab493650d648ab8dca651ea2698861f926e895 (diff) | |
| download | emacs-0065d05491ce5981ea20896bb26d21dcd31e6769.tar.gz emacs-0065d05491ce5981ea20896bb26d21dcd31e6769.zip | |
Adjust in response to jan.h.d's comments.
See, for example <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9196#26>.
Diffstat (limited to 'src/xterm.c')
| -rw-r--r-- | src/xterm.c | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/src/xterm.c b/src/xterm.c index 4ef0061dba6..2c973d6b967 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -1628,11 +1628,8 @@ x_color_cells (Display *dpy, int *ncells) | |||
| 1628 | int ncolor_cells = XDisplayCells (dpy, XScreenNumberOfScreen (screen)); | 1628 | int ncolor_cells = XDisplayCells (dpy, XScreenNumberOfScreen (screen)); |
| 1629 | int i; | 1629 | int i; |
| 1630 | 1630 | ||
| 1631 | if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (XColor) < ncolor_cells) | 1631 | dpyinfo->color_cells = xnmalloc (ncolor_cells, |
| 1632 | memory_full (SIZE_MAX); | 1632 | sizeof *dpyinfo->color_cells); |
| 1633 | dpyinfo->color_cells | ||
| 1634 | = (XColor *) xmalloc (ncolor_cells | ||
| 1635 | * sizeof *dpyinfo->color_cells); | ||
| 1636 | dpyinfo->ncolor_cells = ncolor_cells; | 1633 | dpyinfo->ncolor_cells = ncolor_cells; |
| 1637 | 1634 | ||
| 1638 | for (i = 0; i < ncolor_cells; ++i) | 1635 | for (i = 0; i < ncolor_cells; ++i) |
| @@ -4228,20 +4225,15 @@ x_send_scroll_bar_event (Lisp_Object window, int part, int portion, int whole) | |||
| 4228 | 4225 | ||
| 4229 | if (i == scroll_bar_windows_size) | 4226 | if (i == scroll_bar_windows_size) |
| 4230 | { | 4227 | { |
| 4231 | ptrdiff_t new_size, old_nbytes, nbytes; | 4228 | ptrdiff_t old_nbytes = |
| 4232 | /* Check the 32-bit XClientMessageEvent limit, as well as the | 4229 | scroll_bar_windows_size * sizeof *scroll_bar_windows; |
| 4233 | usual ptrdiff_t/size_t limit. */ | 4230 | ptrdiff_t nbytes; |
| 4234 | if (min (0x7fffffff, | 4231 | enum { XClientMessageEvent_MAX = 0x7fffffff }; |
| 4235 | min (PTRDIFF_MAX, SIZE_MAX) / sizeof *scroll_bar_windows / 2) | 4232 | scroll_bar_windows = |
| 4236 | < scroll_bar_windows_size) | 4233 | xpalloc (scroll_bar_windows, &scroll_bar_windows_size, 1, |
| 4237 | memory_full (SIZE_MAX); | 4234 | XClientMessageEvent_MAX, sizeof *scroll_bar_windows); |
| 4238 | new_size = max (10, 2 * scroll_bar_windows_size); | 4235 | nbytes = scroll_bar_windows_size * sizeof *scroll_bar_windows; |
| 4239 | nbytes = new_size * sizeof *scroll_bar_windows; | ||
| 4240 | old_nbytes = scroll_bar_windows_size * sizeof *scroll_bar_windows; | ||
| 4241 | scroll_bar_windows = (struct window **) xrealloc (scroll_bar_windows, | ||
| 4242 | nbytes); | ||
| 4243 | memset (&scroll_bar_windows[i], 0, nbytes - old_nbytes); | 4236 | memset (&scroll_bar_windows[i], 0, nbytes - old_nbytes); |
| 4244 | scroll_bar_windows_size = new_size; | ||
| 4245 | } | 4237 | } |
| 4246 | 4238 | ||
| 4247 | scroll_bar_windows[i] = w; | 4239 | scroll_bar_windows[i] = w; |
| @@ -5824,6 +5816,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, | |||
| 5824 | struct coding_system coding; | 5816 | struct coding_system coding; |
| 5825 | XEvent event = *eventptr; | 5817 | XEvent event = *eventptr; |
| 5826 | Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; | 5818 | Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; |
| 5819 | USE_SAFE_ALLOCA; | ||
| 5827 | 5820 | ||
| 5828 | *finish = X_EVENT_NORMAL; | 5821 | *finish = X_EVENT_NORMAL; |
| 5829 | 5822 | ||
| @@ -6530,11 +6523,6 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, | |||
| 6530 | if (nchars < nbytes) | 6523 | if (nchars < nbytes) |
| 6531 | { | 6524 | { |
| 6532 | /* Decode the input data. */ | 6525 | /* Decode the input data. */ |
| 6533 | ptrdiff_t require; | ||
| 6534 | |||
| 6535 | if (min (PTRDIFF_MAX, SIZE_MAX) / MAX_MULTIBYTE_LENGTH | ||
| 6536 | < nbytes) | ||
| 6537 | memory_full (SIZE_MAX); | ||
| 6538 | 6526 | ||
| 6539 | /* The input should be decoded with `coding_system' | 6527 | /* The input should be decoded with `coding_system' |
| 6540 | which depends on which X*LookupString function | 6528 | which depends on which X*LookupString function |
| @@ -6547,9 +6535,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, | |||
| 6547 | gives us composition information. */ | 6535 | gives us composition information. */ |
| 6548 | coding.common_flags &= ~CODING_ANNOTATION_MASK; | 6536 | coding.common_flags &= ~CODING_ANNOTATION_MASK; |
| 6549 | 6537 | ||
| 6550 | require = MAX_MULTIBYTE_LENGTH * nbytes; | 6538 | SAFE_NALLOCA (coding.destination, MAX_MULTIBYTE_LENGTH, |
| 6551 | coding.destination = alloca (require); | 6539 | nbytes); |
| 6552 | coding.dst_bytes = require; | 6540 | coding.dst_bytes = MAX_MULTIBYTE_LENGTH * nbytes; |
| 6553 | coding.mode |= CODING_MODE_LAST_BLOCK; | 6541 | coding.mode |= CODING_MODE_LAST_BLOCK; |
| 6554 | decode_coding_c_string (&coding, copy_bufptr, nbytes, Qnil); | 6542 | decode_coding_c_string (&coding, copy_bufptr, nbytes, Qnil); |
| 6555 | nbytes = coding.produced; | 6543 | nbytes = coding.produced; |
| @@ -7008,6 +6996,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, | |||
| 7008 | count++; | 6996 | count++; |
| 7009 | } | 6997 | } |
| 7010 | 6998 | ||
| 6999 | SAFE_FREE (); | ||
| 7011 | *eventptr = event; | 7000 | *eventptr = event; |
| 7012 | return count; | 7001 | return count; |
| 7013 | } | 7002 | } |