aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/coding.c b/src/coding.c
index 0b42a36543c..85b97ce6174 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -1008,11 +1008,12 @@ coding_change_destination (struct coding_system *coding)
1008static void 1008static void
1009coding_alloc_by_realloc (struct coding_system *coding, ptrdiff_t bytes) 1009coding_alloc_by_realloc (struct coding_system *coding, ptrdiff_t bytes)
1010{ 1010{
1011 if (STRING_BYTES_BOUND - coding->dst_bytes < bytes) 1011 ptrdiff_t newbytes;
1012 if (INT_ADD_WRAPV (coding->dst_bytes, bytes, &newbytes)
1013 || SIZE_MAX < newbytes)
1012 string_overflow (); 1014 string_overflow ();
1013 coding->destination = xrealloc (coding->destination, 1015 coding->destination = xrealloc (coding->destination, newbytes);
1014 coding->dst_bytes + bytes); 1016 coding->dst_bytes = newbytes;
1015 coding->dst_bytes += bytes;
1016} 1017}
1017 1018
1018static void 1019static void
@@ -7048,14 +7049,12 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
7048 if ((dst_end - dst) / MAX_MULTIBYTE_LENGTH < to_nchars) 7049 if ((dst_end - dst) / MAX_MULTIBYTE_LENGTH < to_nchars)
7049 { 7050 {
7050 eassert (growable_destination (coding)); 7051 eassert (growable_destination (coding));
7051 if (((min (PTRDIFF_MAX, SIZE_MAX) - (buf_end - buf)) 7052 ptrdiff_t dst_size;
7052 / MAX_MULTIBYTE_LENGTH) 7053 if (INT_MULTIPLY_WRAPV (to_nchars, MAX_MULTIBYTE_LENGTH,
7053 < to_nchars) 7054 &dst_size)
7055 || INT_ADD_WRAPV (buf_end - buf, dst_size, &dst_size))
7054 memory_full (SIZE_MAX); 7056 memory_full (SIZE_MAX);
7055 dst = alloc_destination (coding, 7057 dst = alloc_destination (coding, dst_size, dst);
7056 buf_end - buf
7057 + MAX_MULTIBYTE_LENGTH * to_nchars,
7058 dst);
7059 if (EQ (coding->src_object, coding->dst_object)) 7058 if (EQ (coding->src_object, coding->dst_object))
7060 { 7059 {
7061 coding_set_source (coding); 7060 coding_set_source (coding);