aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorPaul Eggert2011-09-03 16:03:38 -0700
committerPaul Eggert2011-09-03 16:03:38 -0700
commitb49e353d9d01adbe60bc5d0b1658b4ef978b0b06 (patch)
tree9f2ffa6f7a6562abf661a4951012b488ad8b1ae7 /src/coding.c
parent74b880cbc18bd0194c7b1fc44c4a983ee05adae2 (diff)
parentbc3200871917d5c54c8c4299a06bf8f8ba2ea02d (diff)
downloademacs-b49e353d9d01adbe60bc5d0b1658b4ef978b0b06.tar.gz
emacs-b49e353d9d01adbe60bc5d0b1658b4ef978b0b06.zip
Merge from trunk.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/coding.c b/src/coding.c
index 65c8a767c2b..5fd59d394d9 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -5838,7 +5838,7 @@ coding_charset_list (struct coding_system *coding)
5838Lisp_Object 5838Lisp_Object
5839coding_system_charset_list (Lisp_Object coding_system) 5839coding_system_charset_list (Lisp_Object coding_system)
5840{ 5840{
5841 int id; 5841 ptrdiff_t id;
5842 Lisp_Object attrs, charset_list; 5842 Lisp_Object attrs, charset_list;
5843 5843
5844 CHECK_CODING_SYSTEM_GET_ID (coding_system, id); 5844 CHECK_CODING_SYSTEM_GET_ID (coding_system, id);
@@ -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
@@ -8076,7 +8079,7 @@ detect_coding_system (const unsigned char *src,
8076 Lisp_Object attrs, eol_type; 8079 Lisp_Object attrs, eol_type;
8077 Lisp_Object val = Qnil; 8080 Lisp_Object val = Qnil;
8078 struct coding_system coding; 8081 struct coding_system coding;
8079 int id; 8082 ptrdiff_t id;
8080 struct coding_detection_info detect_info; 8083 struct coding_detection_info detect_info;
8081 enum coding_category base_category; 8084 enum coding_category base_category;
8082 int null_byte_found = 0, eight_bit_found = 0; 8085 int null_byte_found = 0, eight_bit_found = 0;