aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/coding.c b/src/coding.c
index 73a4bbc5e25..5fd59d394d9 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -6683,8 +6683,12 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6683 break; 6683 break;
6684 } 6684 }
6685 6685
6686 if (dst + MAX_MULTIBYTE_LENGTH * to_nchars > dst_end) 6686 if ((dst_end - dst) / MAX_MULTIBYTE_LENGTH < to_nchars)
6687 { 6687 {
6688 if (((min (PTRDIFF_MAX, SIZE_MAX) - (buf_end - buf))
6689 / MAX_MULTIBYTE_LENGTH)
6690 < to_nchars)
6691 memory_full (SIZE_MAX);
6688 dst = alloc_destination (coding, 6692 dst = alloc_destination (coding,
6689 buf_end - buf 6693 buf_end - buf
6690 + MAX_MULTIBYTE_LENGTH * to_nchars, 6694 + MAX_MULTIBYTE_LENGTH * to_nchars,
@@ -7888,11 +7892,10 @@ encode_coding_object (struct coding_system *coding,
7888 } 7892 }
7889 else if (EQ (dst_object, Qt)) 7893 else if (EQ (dst_object, Qt))
7890 { 7894 {
7895 ptrdiff_t dst_bytes = max (1, coding->src_chars);
7891 coding->dst_object = Qnil; 7896 coding->dst_object = Qnil;
7892 coding->dst_bytes = coding->src_chars; 7897 coding->destination = (unsigned char *) xmalloc (dst_bytes);
7893 if (coding->dst_bytes == 0) 7898 coding->dst_bytes = dst_bytes;
7894 coding->dst_bytes = 1;
7895 coding->destination = (unsigned char *) xmalloc (coding->dst_bytes);
7896 coding->dst_multibyte = 0; 7899 coding->dst_multibyte = 0;
7897 } 7900 }
7898 else 7901 else