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/term.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/term.c')
| -rw-r--r-- | src/term.c | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/src/term.c b/src/term.c index bc6fa8f80f9..f3bf3a947cb 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -551,12 +551,10 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi | |||
| 551 | 551 | ||
| 552 | if (encode_terminal_src_size - nbytes < required) | 552 | if (encode_terminal_src_size - nbytes < required) |
| 553 | { | 553 | { |
| 554 | ptrdiff_t size; | 554 | encode_terminal_src = |
| 555 | if (min (PTRDIFF_MAX, SIZE_MAX) - nbytes < required) | 555 | xpalloc (encode_terminal_src, &encode_terminal_src_size, |
| 556 | memory_full (SIZE_MAX); | 556 | required - (encode_terminal_src_size - nbytes), |
| 557 | size = nbytes + required; | 557 | -1, 1); |
| 558 | encode_terminal_src = xrealloc (encode_terminal_src, size); | ||
| 559 | encode_terminal_src_size = size; | ||
| 560 | buf = encode_terminal_src + nbytes; | 558 | buf = encode_terminal_src + nbytes; |
| 561 | } | 559 | } |
| 562 | 560 | ||
| @@ -629,13 +627,9 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi | |||
| 629 | nbytes = buf - encode_terminal_src; | 627 | nbytes = buf - encode_terminal_src; |
| 630 | if (encode_terminal_src_size - nbytes < MAX_MULTIBYTE_LENGTH) | 628 | if (encode_terminal_src_size - nbytes < MAX_MULTIBYTE_LENGTH) |
| 631 | { | 629 | { |
| 632 | ptrdiff_t size; | 630 | encode_terminal_src = |
| 633 | if (min (PTRDIFF_MAX, SIZE_MAX) - MAX_MULTIBYTE_LENGTH | 631 | xpalloc (encode_terminal_src, &encode_terminal_src_size, |
| 634 | < nbytes) | 632 | MAX_MULTIBYTE_LENGTH, -1, 1); |
| 635 | memory_full (SIZE_MAX); | ||
| 636 | size = nbytes + MAX_MULTIBYTE_LENGTH; | ||
| 637 | encode_terminal_src = xrealloc (encode_terminal_src, size); | ||
| 638 | encode_terminal_src_size = size; | ||
| 639 | buf = encode_terminal_src + nbytes; | 633 | buf = encode_terminal_src + nbytes; |
| 640 | } | 634 | } |
| 641 | if (CHAR_BYTE8_P (c) | 635 | if (CHAR_BYTE8_P (c) |
| @@ -665,12 +659,11 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi | |||
| 665 | nbytes = buf - encode_terminal_src; | 659 | nbytes = buf - encode_terminal_src; |
| 666 | if (encode_terminal_src_size - nbytes < SBYTES (string)) | 660 | if (encode_terminal_src_size - nbytes < SBYTES (string)) |
| 667 | { | 661 | { |
| 668 | ptrdiff_t size; | 662 | encode_terminal_src = |
| 669 | if (min (PTRDIFF_MAX, SIZE_MAX) - SBYTES (string) < nbytes) | 663 | xpalloc (encode_terminal_src, &encode_terminal_src_size, |
| 670 | memory_full (SIZE_MAX); | 664 | (SBYTES (string) |
| 671 | size = nbytes + SBYTES (string); | 665 | - (encode_terminal_src_size - nbytes)), |
| 672 | encode_terminal_src = xrealloc (encode_terminal_src, size); | 666 | -1, 1); |
| 673 | encode_terminal_src_size = size; | ||
| 674 | buf = encode_terminal_src + nbytes; | 667 | buf = encode_terminal_src + nbytes; |
| 675 | } | 668 | } |
| 676 | memcpy (buf, SDATA (string), SBYTES (string)); | 669 | memcpy (buf, SDATA (string), SBYTES (string)); |
| @@ -1161,16 +1154,16 @@ calculate_costs (struct frame *frame) | |||
| 1161 | X turns off char_ins_del_ok. */ | 1154 | X turns off char_ins_del_ok. */ |
| 1162 | 1155 | ||
| 1163 | max_frame_cols = max (max_frame_cols, FRAME_COLS (frame)); | 1156 | max_frame_cols = max (max_frame_cols, FRAME_COLS (frame)); |
| 1164 | if ((min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) - 1) / 2 < max_frame_cols) | 1157 | if ((min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) - 1) / 2 |
| 1158 | < max_frame_cols) | ||
| 1165 | memory_full (SIZE_MAX); | 1159 | memory_full (SIZE_MAX); |
| 1166 | 1160 | ||
| 1167 | char_ins_del_vector | 1161 | char_ins_del_vector = |
| 1168 | = (int *) xrealloc (char_ins_del_vector, | 1162 | xrealloc (char_ins_del_vector, |
| 1169 | (sizeof (int) | 1163 | (sizeof (int) + 2 * sizeof (int) * max_frame_cols)); |
| 1170 | + 2 * max_frame_cols * sizeof (int))); | ||
| 1171 | 1164 | ||
| 1172 | memset (char_ins_del_vector, 0, | 1165 | memset (char_ins_del_vector, 0, |
| 1173 | (sizeof (int) + 2 * max_frame_cols * sizeof (int))); | 1166 | (sizeof (int) + 2 * sizeof (int) * max_frame_cols)); |
| 1174 | 1167 | ||
| 1175 | 1168 | ||
| 1176 | if (f && (!tty->TS_ins_line && !tty->TS_del_line)) | 1169 | if (f && (!tty->TS_ins_line && !tty->TS_del_line)) |